Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Problem including custom library
Problem including custom library [message #651817] Tue, 01 February 2011 12:30 Go to next message
Eclipse UserFriend
Hi,
I'm using Helios, 3.6.1, in Ubuntu 10.04.

I created a library.so using CDT and now I intend to use it in another project (which also includes a Qt interface).

I copied the library.so file into a folder of the project called libs.
In project->properties->C/C++ Include Path I added that folder.
In project->properties->C/C++ Project Paths->Libraries I added the library.so file.

The g++ line looks like this:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Ilibs -Idebug -I. -o debug/main.o main.cpp

The references in the project to objects from the library are tagged as errors (does not name a type), and the inclusions of classes from that library as well (no such file or directory).

The main problem (and therefore the essence of my doubt here) is how inclusions of external libraries work in CDT. I've read the manuals and tried all solutions I found online, but usually the version of eclipse is different from mine (and I don't have the same menu options).

Once I solve this I still have to work out how to make the library usable by Qt, but that's my problem (now I'm just whining a little).

Thanks to anyone even reading this.
Re: Problem including custom library [message #651952 is a reply to message #651817] Wed, 02 February 2011 03:21 Go to previous messageGo to next message
Eclipse UserFriend
I guess you forgot to extend the library search path for the linker. See here for more details
http://wiki.eclipse.org/CDT/User/FAQ#Adding_C.2FC.2B.2B_Exte rnal_Libraries
Re: Problem including custom library [message #651956 is a reply to message #651952] Wed, 02 February 2011 04:12 Go to previous messageGo to next message
Eclipse UserFriend
When I said I do not have the same menu options as some online solutions, that page was included.
In Helios there is no "C/C++ Build" in project->properties.

There isn't a single mention to Linker either, so if the linker was to be the problem, I would not know how to fix it.

Here is the menu I have explained:
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. cdt.doc.user/reference/cdt_u_prop_build_discovery.htm

EDIT: In fact, is not exactly that menu, but most options are the same.

[Updated on: Wed, 02 February 2011 04:20] by Moderator

Re: Problem including custom library [message #652010 is a reply to message #651956] Wed, 02 February 2011 07:29 Go to previous messageGo to next message
Eclipse UserFriend
Please reread your and my post.
Quote:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -Ilibs -Idebug -I. -o debug/main.o main.cpp


You want your program link against the two libs "libs" and "debug" and some Qt libs (option -l is for the linker). The linker will find the Qt libs because he has the full path for them. But the linker will not find the other two libs. If you look at the output of the build console you will see a linker error about not finding these libs. You mentioned these errors.
Quote:
The references in the project to objects from the library are tagged as errors (does not name a type), and the inclusions of classes from that library as well (no such file or directory).


Quote:
In Helios there is no "C/C++ Build" in project->properties.

Of course, it is there. Every C/C++ project in Helios has this page. Is it possible that you use the Qt integration plugin?
Re: Problem including custom library [message #652018 is a reply to message #652010] Wed, 02 February 2011 08:10 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for you time Axel,

watching my menu I realized there is a Qt tab, which may mean I'm using the Qt integration plugin as you said:
http://img141.imageshack.us/img141/5172/propertiesxi.png
In that case I may be in the wrong forum.

Anyway, the build console gives no error regarding the unfound libraries in the linker. All appearing errors in it are within the project code, the "no such file or directory" for the files from the library and the "does not name a type" for the instances from the library.

That is probably caused because in the g++ line it does not appear the library itself. So it is actually not looking for it.
The g++ line appearing in the above image is the one I'm adding stuff to (my library is called libCCCI.so, hence the -lCCCI ) but the g++ seems to ignore that, since in the console the -lCCCI does not appear.

Maybe I'm trying to solve the problem in the wrong place and modifying the wrong parameters.

[Updated on: Wed, 02 February 2011 08:12] by Moderator

Re: Problem including custom library [message #652215 is a reply to message #652018] Thu, 03 February 2011 02:24 Go to previous messageGo to next message
Eclipse UserFriend
Dario wrote on Wed, 02 February 2011 14:10
Thank you for you time Axel,

watching my menu I realized there is a Qt tab, which may mean I'm using the Qt integration plugin as you said:
http://img141.imageshack.us/img141/5172/propertiesxi.png


Well, I actually never used the Qt integration plugin but we are using Qt here. You have to add the library to your Qt project file (..pro). You should open your .pro and add the library there.
Re: Problem including custom library [message #652226 is a reply to message #652215] Thu, 03 February 2011 03:52 Go to previous message
Eclipse UserFriend
OK, problem solved.
It was indeed a Qt problem, so apologies for the out-of-topic.

As a matter of fact, I missed the header files. I thought that adding the .so library was enough, but seems like the .h are also necessary. Coping them to the libs folder made the trick.

Thanks for your time Axel.
Previous Topic:Crash in getSourceLookupPath() when starting GDB
Next Topic:Inserting tabs when my code style has them disabled
Goto Forum:
  


Current Time: Sun Jul 27 11:29:59 EDT 2025

Powered by FUDForum. Page generated in 0.04545 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top