ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
hello, i been having this problem for about a week now, and i cant seem to find out how to fix it
whenever i try to compile a c program, the linker gives that "undefined symbol" stuff
i have 2 separate small projects i tried to compile, one just be trying to learn how to use the xml library, and the other is a multi file c program just for fun, both compile fine with only some small warnings, the usually stuff like "inter to pointer without a cast" or ignorable stuff like that ... all the problem come at compile time, and its always the linker giving that undefined symbol stuff, and it only does that to included files for some reason ... anyways, heres the output from the xml one (just because thats smallest)
gcc -o test filetypes.c -I/usr/include/libxml2 -L/usr/lib -lxml -lz
compile no problems .. then
filetypes.c: In function `filetypearraycreater':
filetypes.c:17: warning: return makes integer from pointer without a cast
/tmp/ccWH8GFs.o(.text+0x110): In function `createfiletypesfile':
: undefined reference to `xmlSaveFormatFile'
/tmp/ccWH8GFs.o(.text+0x125): In function `createfiletypesfile':
: undefined reference to `xmlSaveFormatFile'
collect2: ld returned 1 exit status
heres the program in question (ill remove the first 2 functions, as they are not used in anyway yet) .. all this does is call a function to create a new xml doc's
thanks ToniT, it was the wrong library name *curses the xml-config that said to use -lxml* ...... but what could be the cause of the same errors in the other program i had?.... i know it wasn't a wrong lib's name, all the errors in linking came from trying to use functions i made,, or in same cases variables ... am i supposed to add "-I" or "-l" options to use those functions and variables ..?
sorry, i haven't responded in a while, i haven't been at my computer for some time
.. anyways, i did the compile the exact same way you showed above Tinkster, no compile errors, some warnings (i fix them later i guess) .. but when its time for the linker to do its think, all i get is "undefined" functions and variables (they were defined in the .h files, the compiler didn't mind them) ... any ideas?, or do i need to include something else to get it to want to work?
all i get is "undefined" functions and variables (they were defined in the .h files, the compiler didn't mind them) ... any ideas?, or do i need to include something else to get it to want to work?
This is a frequent mistake, already discussed several times in this forum.
Functions are *not* defined in header files, but only declared, meaning your C code knows about their name, return value and parameters count and type to verify you use it the proper way.
Functions *are* defined either in libraries, that can be either object (.o) or shared objects files (.so), and are linked with your own objects to build the executable binary.
You can find out if the function you need is present in the xml2 library by using the command: