Hi recently I upgraded gcc to 9.1,but I installed in custom path. All the other dependency libraries i use is also installed in that path. I had set PATH and LIBRARY_PATH to this folder. Whatever previous versions i was using it is still there in system path. Now when I compile my program first it is searching include files in the system path then later my custom path. How can i make so first include search priority to be given to the custom path.
And also i am using eclipse on Ubuntu for development, it is not referring g++ to the new path. Still considering old path. How can i rectify this? Invoking g++, gcc, gdb points to the new path
Related
I'm learning to use OpenCV (and C++) in Codeblocks. What confuses me, however, is that when I start to include header files from OpenCV in my main.cpp file, Codeblocks automatically suggests to me the files as shown in the image below.
I have not included any search paths to project build options, so how is this possible that Codeblocks can find the files? Is there some other variable working here that I'm unaware of?
Note that I'm a beginner with both Codeblocks and OpenCV and that I only have a little experience with C++.
Thank you
Of course when you install an IDE like code::blocks by default, it knows about standard path for library on your OS.
On my OS -> Ubuntu that is /usr/include
It only searches on a standard path, except you add one. If you install your library by command-line, it goes to the standard place, if you installed manually, then it depends on your option you added to installation. I can not see you screen-shot but it has access to /usr/include by default.
For more detail on Linux and OpenCV
And here is a screen-shot of codeblock on Ubuntu that I added some 3rd-party library
NOTE:
if you install any libraries by command-line, just use it.
But if you have installed them manually, you need to add 2 things to codeblock.
1. First is your path for header file
2. Second is your path for linker
And you see it in screen-shot that say: Search Directory
First is for header and second is for linker
i just installed gcc 4.9 using the link here and it is a very good link. But I have only one problem which i dont want to try not to mess up --> linking the libraries and path variables.
we have a cluster in our college and i installed this in my home directory (without root). Now my home/ directory contains this folder where all the gcc folders are :
bin
include
lib
lib64
libexec
share
What all do i have to do to point to the g++/gcc binary in bin folder with additional linking ? For example, set ld_library_path, set binary paths (export PATH = /home/asdf/gcc4.9/bin:$PATH) . etc..
Can anyone provide details on what all needs to be done to use gcc/g++ 4.9 (installed by me) by bypassing the older version of gcc installed by root.
Do i have to add lib and lib64 to the ld_library_paths as well ? Will i have to use " " instead of < > to include files (e.g. # inlcude "set" or #include and it includes from gcc4.9 and not the old one ) Or explicitly provide the include path using -I
Any suggestions/discussions/comments are welcome. I am aware this may marked as duplicate, but it will really be useful to all the people out there who want to try the new gcc-4.9 with c++11 without messing up the environment variables.
PS: I am not asking how to export or set an environment variable. I am asking what all environment variables are required to use my non-root version of gcc and not the root's older version and not mess up the ld paths and so paths during runtime.
thanks !!
If you build your compiler with --prefix=/home/myname/gcc4.9 (adjust to match your system, obviously), then the compiler should "know" that the include paths etc.
All you need beyond that is to make sure your path has /home/myname/gcc4.9/bin before /usr/bin or wherever your other gcc is installed, and everything should work just like normal. On my machine, I have gcc 4.8.2 installed from my own build and gcc 4.6.3 from the linux installer for gcc (because it's a fairly old distro). And as long as I have the paths set in the right order, it works "automagically".
You will need to set LD_LIBRARY_PATH, but include-paths and static libraries should be handled by gcc itself.
I have a C++ project I am importing and it is using activemq libraries. After I import the project, I set the LD_LIBRARY_PATH variable under environment to point to
/usr/local/include/activemq-cpp-3.4.2
This allows the project to see all the libraries for activemq and I can see it show up in my includdes folder in the project explorer. When I go to Build Project, I am getting tons of errors to references of includes/objects that are inside /usr/local/include/activemq-cpp-3.4.2. The interesting thing is that the binary is still being produced, yet there are about 80 errors due to the library files not being found. How is the binary being made? Also, what must I do to the LD_LIBRARY_PATH environment variable so the project is properly including those files?
I have tried launching eclipse with the
./eclipse -clean
But that didn't seem to help. Any ideas are welcome, and thank you in advance!
EDIT:
I am using Eclipse Juno with C++ verseion 4.1.2 on Redhat 4.X
LD_LIBRARY_PATH isn't used for locating include directories. It's used to inform the system of a list of directories to search for shared libraries: compiled support libraries, not e.g. SDKs for Eclipse.
You should use the project's properties to add to the places that are searched for includes: C++ General->Paths and Symbols->Includes
Also use the properties - not LD_LIBRARY_PATH - if you do need to link against other libraries: : C++ General->Paths and Symbols->Library Paths
Finding header files is not the purpose of LD_LIBRARY_PATH. That environment variable is to tell the OS where to start looking for shared libraries — *.so files. The OS looks for those when preparing the execute your program. The compiler uses the include path to search for headers when it encounters an #include statement in your source code.
Don't modify LD_LIBRARY_PATH to affect compilation of your program.
Eclipse lets you set your include path in your project options.
I would like to add some extra include/lib directories besides the default ones for MinGW to search upon compilation. The reason for this is because the hard drive I currently have MinGW installed into is nearly full and so I had to install Qt into my second one instead. Thus, how can I have MinGW include the Qt files by default?
You can set environment variables CPLUS_INCLUDE_PATH for include directories and LIBRARY_PATH for library directories. More information can be found in Environment Variables Affecting GCC
Use -Idirective for extra includes and -Ldirective for extra library paths such as:
g++ [...] -I C:\qt\include -L C:\qt\lib
You can use multiple -Iand -Loptions.
I'm using Eclipse-CDT to develop and compile projects for Linux. As host both Linux or Windows may be used.
The project is created as Makefile project with a special build command, so I changed the build-command from make to our special one and the "Build" and "Clean" commandline approbriately. The build command uses a gcc from a directory not in $PATH, because the whole compiler-suite is located in the version control system. (Correct $PATH is set by the build command.)
This works fine under Linux: Eclipse learns the Symbols and Include Files automatically.
However, under Windows the Symbols are recognized, but the Include Paths aren't.
When I have a look in the generated MyProject.sc file in the workspace/.metadata/.plugins/org.eclipse.cdt.make.core directory, I see that the Include-Files are recognized, but prepended with a C:\cygwin.
The GCC command line uses absolute paths without the Drive letter.
(The whole source tree is located on a special Drive (e.g. W:), CWD is on this drive ).
E.g. gcc/g++ is invoked with -I /net_libs/lib1/inc and Eclipse recognizes C:\cygwin\net_libs\lib1\inc.
BTW: The standard-include paths are recognized correctly (e.g. W:/toolchain/win32/i686-pc-linux-gnu/include/c++/4.2.1).
The Build-Directory is set to the directory of the Makefile which is on the same Drive as the Sources and Includes.
I tried various "Toolchain" settings (Cygwin, MinGw, Linux gcc), the result is same every time. (After changing the settings, I even stopped Eclipse, deleted the sc file and started Eclipse again).
I don't know why Eclipse knows about my Cygwin installation in C:\Cygwin - the installation is NOT used by the compiler or related tools.
When I change the .sc file manually and correct the paths and restart Eclipse, everything works fine.
Do you have any hints what may be the problem?
Have a look at Project->Propterties->C/C++ Build->Discovery Options.
There is a Compiler invocation command - usually set to gcc, which means "gcc in PATH". Try setting this to your gcc from your build system.