Question

Hello Dearest Internet,

So, I've downloaded the clAmdFft library found here.

I've also went ahead and done this, (adding source files/libraries to compiler/system paths). Here they are after the fact:

echo $LIBRARY_PATH
/usr/lib:/opt/clAmdFft-1.10.321/lib64:/usr/lib:
echo $C_INCLUDE_PATH
/opt/clAmdFft-1.10.321/include:
echo $LD_LIBRARY_PATH
/opt/clAmdFft-1.10.321/lib64:/opt/clAmdFft-1.10.321/lib32:/usr/lib:/usr/local/cuda/lib64:/usr/local/cuda/lib::/opt/clAmdFft-1.10.321

Here is the top of one of the .cpp files that I would like to use this library in:

// AMD APPML FFT
#include <clAmdFft.h>
// IVE TRIED THESE TOO
//#include "clAmdFft.h"
//#include <clAmdFft>

And finally, here is my sugar sweet Makefile, (nothing real complicated here, I've done it like this consistently before)

#
#
#  Compile Super Mega Awesome Program For Winners
#
#
#

# -std=c++0x is required for using <chrono>

objects =  L1.o L2.o L3.o 
sharedObjects = SL1.so
exec = SL1
GCC=gcc
GPP=g++
CFLAGS= -I /usr/local/cuda/include -g
LDFLAGS = -L /usr/lib -lOpenCL

# This apparently addresses linking problems w/ clAmdFft & NVIDIA drivers
LDFLAGS += -Wl,--unresolved-symbols=ignore-in-shared-libs

SL1: 
        $(GPP) $(CFLAGS) -o L1.o -c -std=c++0x -fPIC main.cpp       
        $(GPP) $(CFLAGS) -o L2.o -c -fPIC L2.cpp
        $(GPP) $(CFLAGS) -o L3.o -c -fPIC L3.cpp
        $(GPP) $(CFLAGS) -Wall -shared  -o $(sharedObjects) $(objects)
        $(GPP) $(sharedObjects) -o $(exec) -g $(LDFLAGS)

.PHONY : clean
clean: 
        rm $(objects) $(sharedObjects) $(exec)




#EOF

Why then, dear Internet, do I get the following error?

L3.cpp:24:22: fatal error: clAmdFft.h: No such file or directory
compilation terminated.

I mean this seems very straightforward. After a quick perusal of this site as well as google in general, I can't seem to find a solid answer as to why this isn't working right meow. Hope you guys can help! Thanks.

Was it helpful?

Solution

As in the comment, adding the -I /opt/clAmdFft-1.10.321/include to the CFLAGS= -I /usr/local/cuda/include -g is my preferred way to solve this particular problem.

As to how to use C_INCLUDE_PATH, technically your usage is correct - except you are not compiling the code with gcc but with g++ and thus you should use CPLUS_INCLUDE_PATH.

Here's a compile-example (not showing my xemacs session creating testing.cpp and testing.h - testing.cpp simply doing #include <testing.h> (which contains a simple define that I'm printing).

$ mkdir ../testing
$ export C_INCLUDE_PATH=../testing
$ g++ -Wall testing.cpp
testing.cpp:2:21: fatal error: testing.h: No such file or directory
compilation terminated.
$ export CPLUS_INCLUDE_PATH=../testing
$ g++ -Wall testing.cpp

However, the whole point of using makefiles is that they define what you get included from where. Using global environment variables will just lead to your project depending on what each user on the system has configured their C_INCLUDE_PATH and CPLUS_INCLUDE_PATH.

Likewise, if you end up moving your project from one machine to another, if all the include-paths, etc, are in the makefile, you can just copy the project files [and install the dependencies, of course - although you CAN have the makefile do that too, if you work at it]. If you rely on CPLUS_INCLUDE_PATH and the like, you end up having to also go edit your .bashrc or whatever.

(And I learned something new today, I didn't even know these environment variables existed).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top