0

I have installed the cds library with command ./build.sh -b 64 -z '-std=c++0x' -l '-L /usr/lib/x86_64-linux-gnu' --with-boost /usr/include/boost --amd64-use-128bit at build folder.

After I tried to compile the example init.cpp of src folder, I typed this in terminal: g++ init.cpp -o init, and terminal showed: fatal error: cds/init.h: No such file or directory.

What should I do for compilation command in this case? Thanks.

Crow C
  • 1
  • 3
  • Is '-L /usr/ib/x86_64-linux-gnu' just a typo? (You probably meant '-L /usr/lib/x86_64-linux-gnu' ) – optisimon Feb 18 '16 at 01:59
  • Thanks for corrected. – Crow C Feb 18 '16 at 02:07
  • Did you install `libcds` or did you just build it? Can you verify that `cds/init.h` is somewhere in `/usr/include` directory? – alvits Feb 18 '16 at 02:14
  • I can't find `cds` folder. So the command `./build.sh -b 64 -z '-std=c++0x' -l '-L /usr/lib/x86_64-linux-gnu' --with-boost /usr/include/boost --amd64-use-128bit` is not for installation? According to this [forum](https://sourceforge.net/p/libcds/discussion/1034512/thread/97cf3473/) – Crow C Feb 18 '16 at 02:24
  • 1
    As the name implies, the script builds it. You still need to install it. Usually done with `make install` if `build.sh` successfully created a `Makefile`. – alvits Feb 18 '16 at 02:33
  • I have a `Makefile` in `build` folder, and I tried to run `make install Makefile` in terminal, output>> `make: ***No rule to make target 'install'. Stop.` – Crow C Feb 18 '16 at 02:54

1 Answers1

0

For general troubleshooting in cases like this, i would recommend finding where on the system the file got installed (if your build.sh actually installed the file). You would be able to find the missing header file using

find / -path '*/cds/init.h' 2>/dev/null

Then you need to supply two parameters to g++:

First one gets the compiler to know about the include files from the install directory

-I path_to_folder_one_step_above_cds_folder

Second one gets the linker to know about the librarys location. If the library file is called libcds.so, you can find it by running

find / -name libcds.so 2>/dev/null

So for linking, you supply the flag

-L path_to_folder_one_step_above_libcds.so

In your case you might not need the -L flag, since most of your library supposedly is header only.

UPDATE: the build.sh script is printing out important information at the top, starting with "Building with the following options:". The important bits will be "Compile options:" and "Link options:". Those should be enough to solve your specific option.

UPDATE2: build.sh also exports some flags which might include more options. You can print them out directly after running build.sh by running

echo LDFLAGS=$LDFLAGS
echo CFLAGS=$CFLAGS
echo CXXFLAGS=$CXXFLAGS

you are likely to need to pass all these options to g++ when compiling and linking against that library. LDFLAGS are specific to the linker only. Both the other ones are needed for compiling c++ files.

optisimon
  • 136
  • 4