Position of compiler flag -l

后端 未结 2 927
孤城傲影
孤城傲影 2021-01-06 13:04

I\'m currently learning OpenCL. Now, when I want to compile my program, I get an error with this command:

g++ -Wall -l OpenCL main.cpp -o main
2条回答
  •  别那么骄傲
    2021-01-06 13:35

    With g++ (and generally under Unix), -l specifies a source of input (either a .a or a .so), and input is processed in order. When the input is a static library (a .a file), it will be scanned for objects which resolve undefined references; if it is a .so, there aren't any object files in it, but it will still only be taken into consideration if it resolves some undefined symbol.

    When you put the -l before any object files, there are no undefined symbols yet, so nothing will be incorporated into the program.

提交回复
热议问题