popt, ELDK 2.0.2
I was experimenting with the popt library in the ELDK 2.0.2, and I received the following errors. The same compiler invocation is successful when used with gcc under Red Hat Linux 7.3. The source code follows the error messages. How do I properly compile and link this file?
ppc_82xx-gcc -Wall -lpopt -o popt_test main.c /tmp/ccMrZmW2.o: In function `main':
/tmp/ccMrZmW2.o(.text+0x60): undefined reference to `poptGetContext' /tmp/ccMrZmW2.o(.text+0x60): relocation truncated to fit: R_PPC_REL24 poptGetContext
/tmp/ccMrZmW2.o(.text+0x70): undefined reference to `poptGetNextOpt' /tmp/ccMrZmW2.o(.text+0x70): relocation truncated to fit: R_PPC_REL24 poptGetNextOpt
/tmp/ccMrZmW2.o(.text+0x94): undefined reference to `poptFreeContext' /tmp/ccMrZmW2.o(.text+0x94): relocation truncated to fit: R_PPC_REL24 poptFreeContext
collect2: ld returned 1 exit status
make: *** [all] Error 1
#include <stdio.h>
#include <stdlib.h>
#include <popt.h>
int main(int argc, char *argv[])
{
int rc;
/* command-line arguments */
struct poptOption options[] = {
{ "help", 'h', POPT_ARG_NONE, NULL, 1 },
{ NULL, 0, 0, NULL, 0 }
};
poptContext context;
context = poptGetContext(NULL, argc, (const char **)argv, options,
0);
rc = poptGetNextOpt( context );
printf("%d\n", rc);
poptFreeContext( context);
return 0;
}/* eof */
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 7 lines · In message <[email protected]> you wrote:
I was experimenting with the popt library in the ELDK 2.0.2, and I received the following errors. The same compiler invocation is successful when used with gcc under Red Hat Linux 7.3. The source code follows the error messages. How do I properly compile and link this file?
ppc_82xx-gcc -Wall -lpopt -o
popt_testmain.c
You must specify the linked objects in the correct order. This means (among other things) that you have to put the libraries AFTER the object files that have references to symbols provided by these libs.
Try:
ppc_82xx-gcc -Wall -o popt_test main.c -lpopt
And RTFM.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: [email protected] Vulcans believe peace should not depend on force.
-- Amanda, "Journey to Babel", stardate 3842.3
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/