1
votes

At first: I am not using an already compiled library.

Here's the situation: I've got a C++ project in eclipse CDT that has a folder structure like this:

project
  somefoldername
    src
    include
  library
    src
    include

somefoldername/src and library/src are defined as source folders and somefoldername/include as well as library/include are defined as include folders (under C/C++ General->Paths and Symbols, which also affects the compilers -I option).

The "library" folder contains the source code of a library used by my own code (which can be found in "somefolder"). Well, compiling of the whole project works fine, but linking crashes with a whole bunch of "undefined reference" errors in the library's source.

The undefined reference errors occur, although *.o-files are created in which the missing functions should be found - and also are passed to the linker afterwards.

What am I doing wrong?

Edit: Updated to current configuration and the attempts to solve the problem.

Edit2: The accepted answer helped me out a bit, but the biggest problem seemed to be the "linking everything at once"-policy followed by eclipse. I went to autoconf and built the library first, before linking it to the main application. Although it's more work, it's a cleaner approach.

1
Q: Have you resolved this yet?paulsm4
Finally, yes. I went through it, together with the author of the library. Some errors came from definitions the library expected to be made by the using source code (which made your point 1) partly right), but few strange things still remained. So I went from the ordinary GCC tool chain to autoconf and built the library seperately, befor linking it to the whole thing. This somehow did the trick. Probably linking all .o-files at once leads to problems. So it wasn't the "extern C"-part, but your first guess solved a part of the problem.aRestless

1 Answers

2
votes

Three possibilities:

1) The "undefined" symbols aren't actually in your library

 This is unlikely, but you can verify using the "nm" Linux command

2) You aren't setting the library search path ("dash-big-L") correctly in Eclipse