I have an issue which sounds annoyingly simple, but I feel I've tried everything to resolve it and I'm out of ideas.
I have a program I wrote which uses boost/program_options.hpp using the include statement
#include <boost/program_options.hpp>
This program works on my laptop and now I am trying to put it onto a server where I don't have sudo privileges. On my laptop, where the whole thing works I have boost versions 1.56 and 1.58 and on the server I found 1.53.0. I didn't install or build this though.
The shared library file that exists on the server is: /usr/lib64/libboost_program_options.so.1.53.0
Running ldd on that gives me the output:
ldd /usr/lib64/libboost_program_options.so.1.53.0
linux-vdso.so.1 => (0x00007ffc54a63000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fc0dcad8000)
libm.so.6 => /lib64/libm.so.6 (0x00007fc0dc7d5000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc0dc5bf000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc0dc1fe000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc0dd071000)
Which I assume means it's found all its dependencies.
I have made a symbolic link to my home directory to create a libboost_program_options.so link, which I guess means the -lboost_program_options linker flag should work.
The way I compile is by:
g++ -L/home/homeDir code.cpp -o code.o -std=c++11 -Wall -lboost_program_options
And all I get is:
fatal error: boost/program_options.hpp: No such file or directory
#include "boost/program_options.hpp"
^
compilation terminated.
I've tried this with quotes and <>, and without "boost/" etc, but I always get the same complaint. I assume this means that it finds the library as there is no complaint about the -lboost_program_options flag?
While it works on my machine, I may not be using the shared program options library at all. On my laptop I have both a static version of libboost_program_options in my library path which it may be using, and the program_options.hpp header outside of a library which may be in my include path. I feel like I should be able to use the shared library that's on the server and not annoy the server admin for the 5th time (things work really slowly with these things here).
I'm sorry if this is my oversight. I'm fairly new to boost, but I feel like I've tried everything to resolve this myself at the moment.
I'd be happy with any suggestions as to how I could change this... or if I'm just being a bit stupid with using shared libraries.
Thanks in advance.
EDIT: After more research I feel like I'm just getting confused between static and shared libraries. I'm trying to link a shared library at compile time, which I guess doesn't make sense. Also including the header file of something which should not be linked at compile time makes little sense. My code is clearly designed for the static library.
The error message is produced by the pre-compiler which does not find the Boost header file (as it says in the error message). You need to set the correct include path (-I...
) where the Boost library header files are found, obviously they are not under /usr/include
.
Path to the Boost libraries (-L...
) must be specified accordingly.
Finally: If you are linking against the Boost shared libraries on your system, then you should use the same version of Boost as installed on the server. Otherwise, link against the static libraries, this may make you executable larger, but it will run on any server, regardless of the Boost version installed there (even none).