I'm new to boost and want to use it with Codelite.
I followed this guide here: Official Boost Guide
Step 1) I installed it to /usr/local/boost_1_67_0/
Step 4) I can compile the example and it works as expected
Step 5) I just ran ./bootstrap.sh and installed everything.
It succeeded and told me
>The Boost C++ Libraries were successfully built!
>
>The following directory should be added to compiler include paths:
>
>/usr/local/boost_1_67_0
>
>The following directory should be added to linker library paths:
>
>/usr/local/boost_1_67_0/stage/lib
So this is what I did in codelite:
6) The example compiles errorlessly with codelite.
>g++ -c "~/Dropbox/MasterThesis/C++/DiracTraceEvaluator/FeynCalc--/main.cpp" -g -O0 -Wall --std=c++11 -o ./Debug/main.cpp.o -I. -I. -I/usr/local/boost_1_67_0/
g++ -o ./Debug/FeynCalc-- #"FeynCalc--.txt" -L. -L./ -L/usr/local/boost_1_67_0/ -L/usr/local/boost_1_67_0/stage/lib/ -lboost_program_options -lboost_regex
Now if I execute the program, I get:
./FeynCalc--: error while loading shared libraries: libboost_regex.so.1.67.0: cannot open shared object file: No such file or directory
I entered /usr/local/boost_1_67_0/stage/lib and all the required files are there. I don't know what else to do.
What solve the issue was
creating a new file in /etc/ld.so.conf.d/
I named it boost.conf
There I entered
# boost_1_67_0 default configuration
/usr/local/boost_1_67_0/stage/lib
Then I ran ldconfig in terminal.
Related
So recently I downloaded the Linux Subsystem on Windows 10, with Ubuntu.
I can compile an SDL2 app to Linux with the g++ command but whenever I try doing it with i686-w64-mingw32-g++ this command, I get an error saying main.cpp:5:9: fatal error: SDL2/SDL.h: No such file or directory.
The command I'm using is i686-w64-mingw32-g++ main.cpp -w -lSDL2 -o main.exe.
https://imgur.com/a/uqcGCoJ
Anyone knows how to fix this? :(
[EDIT]
So now I've tried specifying the directory of the necesary files with this command: g++ main.cpp -I/usr/include/SDL -L/usr/lib/x86_64-linux-gnu -w -Wall -Wextra -std=c++17 -lSDL2 -o main
which worked but when I use it with mingw it doesn't i686-w64-mingw32-g++ main.cpp -I/usr/include/SDL -L/usr/lib/x86_64-linux-gnu -w -Wall -Wextra -std=c++17 -lSDL2 -o main
https://imgur.com/a/sF6CpcP
You need to include the path to SDL's include directory on the command line. However, you need to include the path to the downloaded SDL for mingw32, not /usr/include/SDL2. The difference is the headers in /usr/include/SDL2 are for Linux and libs in /usr/lib are also for Linux, but you need to link to the Windows libraries.
What I usually do is download the development libraries for Mingw32 and put them directly into my project directory. Then all you need to do is add -ISDL2-2.0.8/i686-w64-mingw32/include -LSDL2-2.0.8/i686-w64-mingw32/lib to your command line and it will be able to find the headers and libraries it needs. Finally, make sure you copy SDL2-2.0.8/i686-w64-mingw32/bin/SDL2.dll to your executable directory in the Makefile.
Also, remember to link SDLmain as well. It handles creating a WinMain for you and all that, and then calls your main function.
There are many question asked regarding this issue for example.
I have the library in the path as mentioned in the above link.
export LD_LIBRARY_PATH=/home/mydir/boost_1_66_0/stage/lib
I am using eclipse oxygen, where I added the libraries of boost and pthread like
-l
boost_serialization
pthread
and included the linker path -L /home/mydir/boost_1_66_0/stage/lib and compiler path -l /home/mydir/boost_1_66_0. When I test the program of two files for example thread.cpp and thread.h, it is working fine. But when I include more files it gives me the errror
error while loading shared libraries: libboost_serialization.so.1.66.0: cannot open shared object file: No such file or directory
I am not sure what is going wrong with more files and gives the linking error.
Edit
I tried using makefile, which has something like
CXX = g++
DEBUG = -g
CXXFLAGS = -Wall $(DEBUG) -std=c++17 -boost_serialization -pthread
and it goes on compiling and end with
Building target: Test
Invoking: Cross G++ Linker
g++ -std=c++17 -L/home/mydir/boost_1_66_0/stage/lib -o "Test" ./decodenumbers.o ./encodechars.o ./help.o ./index.o ./inputparameters.o ./loadindex.o ./main.o ./match.o ./output.o ./readfastqfiles.o ./report.o ./reversestrand.o ./samformat.o ./saveindex.o ./time.o ./trimreads.o ./validate.o ./version.o -lboost_serialization -lpthread
Finished building target: Test
When I run, it gives the same issue.
So I had successfully been using cmake and boost in my project.
I wanted to start incorporating armadillo (4.400.1)
I use enivronment modules (http://modules.sourceforge.net/) on my system.
I built with gcc-4.8.1.
CentOS 6.4.
I installed OpenBLAS (0.2.10) and armadillo from source and created environment modules.
In the past I only needed to prepend LD_LIBRARY_PATH with lib directories, but this was not sufficient for armadillo, as I was getting linking errors (unable to find lib) for the following:
g++ example1.cpp -o example1 -O2 -larmadillo
Using the -L option works:
g++ example1.cpp -o example1 -O2 -larmadillo -L${ARMADILLO_HOME}/lib
I am already placing the armadillo lib directory in LD_LIBRARY_PATH. How do I set environment variables so the following will link without error?
g++ example1.cpp -o example1 -O2 -larmadillo
I had to place the armadillo lib directory in the environment variable LIBRARY_PATH not LD_LIBRARY_PATH
Doing this allowed the linking to proceed without error when issuing the command:
g++ example1.cpp -o example1 -O2 -larmadillo
I would like to create a dynamic library for c++ program on linux.
In c++ program/system I`m using libconfig++ library, libpqxx library, some boost and c++11.
My steps:
1)
g++ -Wall -I/usr/local/include/ -std=c++0x -lconfig++ -Wall -lpqxx -lpq -fPIC -c ../SourceFiles/DBHandler.cpp ../SourceFiles/ParamServer.cpp ../SourceFiles/Functions.cpp
2)
g++ -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0 *.o
3)
ln -sf libctest.so.1.0 libctest.so.1
4)
ln -sf libctest.so.1.0 libctest.so
5) compile
g++ -Wall -I/path/to/include-files -L/path/to/libraries program.cpp -I/usr/local/include/ -std=c++0x -lconfig++ -lpqxx -lpq -lctest -o prog
After execute above command :
/usr/bin/ld: cannot find -lctest
collect2: ld returned 1 exit status
What am I doing wrong?
Here is the reference:
enter link description here
In step 5, you forgot -L. to look for libraries in the current directory.
By default, only a [long] list of system directories is used when searching for libraries.
You will also need to add . to the LD_LIBRARY_PATH environment variable before executing your program, so that the current directory is searched at runtime, too. Running ldconfig will avoid this, but if you are only testing your library and do not want to persistently affect your system, I would stick to the LD_LIBRARY_PATH approach.
An alternative is to "install" your library into one of those directories, such as /usr/local/lib (or your equivalent). You should use ldconfig after doing this, so that the dynamic library cache and all your symlinks are set up for you. This is the canonical approach but may not be suitable during iterative development of said library.
You need to ldconfig update the dynamic library cache -- it will also create the symbolic links for you.
See eg Section 3.5 of this Linux Documentation Project HOWTO
I am trying to get mingw gcc to work.
I need it to link with libopengl32.a.
Said file exists in C:/mingw/lib.
I used g++ as follows:
g++ -L"C:/mingw/lib" main.o -o test.exe -llibopengl32.a
It has no trouble finding the includes, it just complains that it can't find the library.
It seems unable to find any other library as well.
Also: I installed all the mingw components manually by downloading them from sourceforge, since using the automatic installer produced a broken installation on my system.
The -l flag automatically adds the lib prefix and the .a extension- you want:
g++ -LC:/mingw/lib main.o -o test.exe -lopengl32
Note you don't need the quotes around the path either. You could also just specify the whole library name & path:
g++ main.o -o test.exe C:/mingw/lib/libopengl32.a
As regards your installation problems, use either http://tdragon.net/recentgcc/ or http://nuwen.net/mingw.html - using the MinGW site itself is a recipe for pain.
You need to use -lopengl32 without "lib" and ".a"