Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » include from not current project (C/C++ question )
include from not current project [message #1820629] Thu, 23 January 2020 22:10 Go to next message
Eclipse UserFriend
I hope I can explain this as PLAIN C++ problem.
It should be OK with Eclipse to "include" source from another project.

The idea is to have ONE place to edit (a class ) and use it independently ,
no "relations" whatsoever in other projects.

I use simple "properties .. settings .. include path ".
It shows up in
project -> includes (see attaches screen shot )
it complies . links but
show up as "undefined reference".

The icon attached to "include RPI_BT_COMMON..." has (!) and the text is grayed .
Obviously no good, but...

I cannot figure out what is wrong , what am I missing OR is "include" from another project no good.

Is including source not enough ( but it complies ) ?
Do I need to make a library and link it to my project ?
Re: include from not current project [message #1820632 is a reply to message #1820629] Fri, 24 January 2020 00:03 Go to previous messageGo to next message
Eclipse UserFriend
Eclipse doesn't really care where your files are.
If you are using a header in your code and expect the Indexer to work
then you need to tell the Indexer how to find the header.
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.

If Eclipse is generating the Makefile
then you need to tell it to tell the compiler where the header can be found.
Project --> Properties --> C/C++ Build --> Settings --> Tool Settings tab

Project --> Properties --> C/C++ General --> Paths and Symbols
is supposed to do both.

Re: include from not current project [message #1820670 is a reply to message #1820632] Sat, 25 January 2020 12:48 Go to previous messageGo to next message
Eclipse UserFriend
This has been a source of "problems" since I started "doing C/C++".
The source - header - "include ..." is OK, what I am missing is a linker option.

So the question is
how to link to the "external source " .


[Updated on: Sat, 25 January 2020 12:49] by Moderator

Re: include from not current project [message #1820672 is a reply to message #1820670] Sat, 25 January 2020 14:27 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
how to link to the "external source "[?]


By telling the linker what libraries to use and where to find them.
If Eclipse is generating the Makefile, it too must be told
which Eclipse will then communicate to the linker via the Makefile.
You tell Eclipse here:
Project --> Properties --> C/C++ Build --> Settings --> Tool Settings tab
OR
Project --> Properties --> C/C++ General --> Paths and Symbols

[Updated on: Sat, 25 January 2020 14:27] by Moderator

Re: include from not current project [message #1820677 is a reply to message #1820672] Sat, 25 January 2020 21:19 Go to previous messageGo to next message
Eclipse UserFriend
OK, I realized that I need to build a library project for the common classes. .

The resulting library full name is "libRPI_BT_LIB.a"
Its path (_L) is in linker libraries option and can be seen in linker output ,
its line (-l) is also in same option and seen in linker output
BUT
the library cannot be found

It LOOKS as linker is looking in wrong place for it .

What am I missing ??


I did try "-llibRPI_BT_LIB.a" with same result
I am hoping enclosing full linker output may help to idetify the issue.


19:58:09 **** Incremental Build of configuration Debug for project PROJECT_A ****
make all
Building target: PROJECT_A
Invoking: GCC C++ Linker
g++ -L/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB -v -o "PROJECT_A" ./src/M_SOCKET_COMMON/CSOCKETCOMMON.o ./src/PROJECT_A.o -lRPI_BT_LIB
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-L/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB' '-v' '-o' 'PROJECT_A' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/cc5WkMUt.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o PROJECT_A /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. ./src/M_SOCKET_COMMON/CSOCKETCOMMON.o ./src/PROJECT_A.o -lRPI_BT_LIB -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -lRPI_BT_LIB
collect2: error: ld returned 1 exit status
make: *** [PROJECT_A] Error 1
makefile:46: recipe for target 'PROJECT_A' failed
"make all" terminated with exit code 2. Build might be incomplete.

19:58:10 Build Failed. 3 errors, 0 warnings. (took 845ms)

[Updated on: Sat, 25 January 2020 21:21] by Moderator

Re: include from not current project [message #1820685 is a reply to message #1820677] Sun, 26 January 2020 07:06 Go to previous messageGo to next message
Eclipse UserFriend
Is it in directory /media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2019-12/Eclipse_2019_12/eclipse/Workspace_2019_12/RPI_BT_LIB?
Or is it in another directory perhaps a subdir like RPI_BT_LIB/lib?

Re: include from not current project [message #1820687 is a reply to message #1820685] Sun, 26 January 2020 10:26 Go to previous message
Eclipse UserFriend
UPDATE
I have build a test library using ALL DEFAULTS.
IDE build shared library so I had to option for "PIC"
Adding (-l) produced expected " cannot find ..."
Adding (-L) path INCLUDING /Debug subdirectory SOLVED the problem.
Moral of the story - check the actual FULL path to the library.
DILEMMA
Make sure the (-L) is changed in release.

PS I did not see David's last note in time to fix this.

Previous Topic:How to modify projects nest?
Next Topic:settings for correct highlighting of my makefile
Goto Forum:
  


Current Time: Sat Jun 14 23:41:41 EDT 2025

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

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

Back to the top