0

I am trying to compile an OpenCL project under Eclipse using Cygwin Gcc/G++ compiler and i got some Undefined References for OpenCL API functions. I saw many threads about this problem, I tried the suggested solutions but I still have these errors.

Basically my code just retrieves OpenCL infos about the platform and device I use so I dont give it here but I can if you want (even if I dont think it is very interesting).

Here is my makefile :

RM := rm -rf

OpenCLEnvInfos.o: ../OpenCLEnvInfos.cpp
       g++ -IINCLUDE_DIR1 -IINCLUDE_DIR2 -g3 -Wall -c ../OpenCLEnvInfos.cpp -o     OpenCLEnvInfos.o
       @echo ' '

OpenCL_infos.o: ../OpenCL_infos.cpp    
       g++ -IINCLUDE_DIR1 -IINCLUDE_DIR2 -g3 -Wall -c ../OpenCL_infos.cpp -o OpenCL_infos.o
       @echo ' '

# All Target
all: OpenCLEnvInfos.exe

# Tool invocations
OpenCLEnvInfos.exe: OpenCLEnvInfos.o OpenCL_infos.o
       g++ -o OpenCLEnvInfos.exe OpenCLEnvInfos.o OpenCL_infos.o -LOpenCL -LGAL-fb
       @echo ' '

# Other Targets
clean:
       -$(RM) OpenCLEnvInfos.o OpenCL_infos.o OpenCLEnvInfos.d OpenCL_infos.d     OpenCLEnvInfos.exe
       @echo ' '

I tried everything (Libs order in linking command), -l instead of -L (but the compiler doesnt find them) ... Eclipse makefile generation make more errors occurs that's why I had to rewrite it...

I hope someone has the answer :p

Baptiste

4

1 回答 1

0

您滥用编译器开关。阅读 GCC 手册以获取更多信息。

-L您应该提供搜索库的目录的路径。在你的情况下,在哪里libOpenCL.aOpenCL.a位于。例如:

-LD:/Libraries/OpenCL/lib

随着-l您指定要链接的库。在你的情况下,那将是libOpenCL.aor OpenCL.a。像这样:

-lOpenCL

顺序是正确的。换句话说,如果这些文件依赖于 指定的库,您应该在所有文件之后-l保留这些开关(在链接阶段的调用中) ,在您的情况下确实如此。*.og++*.o-l

于 2013-10-14T16:51:08.473 回答