<i id='UhSkg'><tr id='UhSkg'><dt id='UhSkg'><q id='UhSkg'><span id='UhSkg'><b id='UhSkg'><form id='UhSkg'><ins id='UhSkg'></ins><ul id='UhSkg'></ul><sub id='UhSkg'></sub></form><legend id='UhSkg'></legend><bdo id='UhSkg'><pre id='UhSkg'><center id='UhSkg'></center></pre></bdo></b><th id='UhSkg'></th></span></q></dt></tr></i><div id='UhSkg'><tfoot id='UhSkg'></tfoot><dl id='UhSkg'><fieldset id='UhSkg'></fieldset></dl></div>
    1. <small id='UhSkg'></small><noframes id='UhSkg'>

        <bdo id='UhSkg'></bdo><ul id='UhSkg'></ul>
      <tfoot id='UhSkg'></tfoot>

        <legend id='UhSkg'><style id='UhSkg'><dir id='UhSkg'><q id='UhSkg'></q></dir></style></legend>

        编译器标志的位置 -l

        Position of compiler flag -l(编译器标志的位置 -l)
              <legend id='ioNA4'><style id='ioNA4'><dir id='ioNA4'><q id='ioNA4'></q></dir></style></legend>
                <tbody id='ioNA4'></tbody>

              <small id='ioNA4'></small><noframes id='ioNA4'>

              • <bdo id='ioNA4'></bdo><ul id='ioNA4'></ul>
                <i id='ioNA4'><tr id='ioNA4'><dt id='ioNA4'><q id='ioNA4'><span id='ioNA4'><b id='ioNA4'><form id='ioNA4'><ins id='ioNA4'></ins><ul id='ioNA4'></ul><sub id='ioNA4'></sub></form><legend id='ioNA4'></legend><bdo id='ioNA4'><pre id='ioNA4'><center id='ioNA4'></center></pre></bdo></b><th id='ioNA4'></th></span></q></dt></tr></i><div id='ioNA4'><tfoot id='ioNA4'></tfoot><dl id='ioNA4'><fieldset id='ioNA4'></fieldset></dl></div>

              • <tfoot id='ioNA4'></tfoot>
                • 本文介绍了编译器标志的位置 -l的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前正在学习 OpenCL.现在,当我想编译我的程序时,我收到以下命令的错误:

                  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
                  

                  错误大多是未定义的引用,因为库没有链接,我想(不过我会在最后贴出错误代码).

                  The errors are mostly undefined references, because the library is not linked, I think (nevertheless I will post the error code at the end).

                  但是使用这个命令一切正常:

                  But with this command everything works fine:

                  g++ -Wall main.cpp -o main -l OpenCL
                  

                  所以我的问题是,我该怎么做才能在命令前面使用 -l 标志?(背景是:我想使用 Netbeans 编译我的程序,当我在 -> 属性 -> 构建 -> C++ 编译器 -> 附加选项下添加标志时,它将放入位置,显示在第一个命令中)

                  So my question is, what do I have to do, to use the -l Flag in front of the command? (The Background is: I want to use Netbeans to compile my programm and when i add the flag under -> properties -> build -> C++ Compiler -> additional options, it will put in in the Position, shown in the first command)

                  预先感谢您的帮助

                  错误代码如下:

                  /tmp/ccmKP4oI.o: In function `cl::detail::ReferenceHandler<_cl_context*>::release(_cl_context*)':
                  main.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP11_cl_contextE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP11_cl_contextE7releaseES3_]+0x14): undefined reference to `clReleaseContext'
                  /tmp/ccmKP4oI.o: In function `cl::detail::ReferenceHandler<_cl_command_queue*>::release(_cl_command_queue*)':
                  main.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP17_cl_command_queueE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP17_cl_command_queueE7releaseES3_]+0x14): undefined reference to `clReleaseCommandQueue'
                  /tmp/ccmKP4oI.o: In function `cl::Platform::getInfo(unsigned int, std::string*) const':
                  main.cpp:(.text._ZNK2cl8Platform7getInfoEjPSs[_ZNK2cl8Platform7getInfoEjPSs]+0x22): undefined reference to `clGetPlatformInfo'
                  /tmp/ccmKP4oI.o: In function `cl::Platform::get(std::vector<cl::Platform, std::allocator<cl::Platform> >*)':
                  main.cpp:(.text._ZN2cl8Platform3getEPSt6vectorIS0_SaIS0_EE[_ZN2cl8Platform3getEPSt6vectorIS0_SaIS0_EE]+0x41): undefined reference to `clGetPlatformIDs'
                  main.cpp:(.text._ZN2cl8Platform3getEPSt6vectorIS0_SaIS0_EE[_ZN2cl8Platform3getEPSt6vectorIS0_SaIS0_EE]+0xb4): undefined reference to `clGetPlatformIDs'
                  collect2: error: ld returned 1 exit status
                  

                  推荐答案

                  g++ [大多数] 参数的顺序非常重要.

                  Order of [most] arguments to g++ is very important.

                  库应该放在最后(至少在源文件和目标文件之后).你无法真正改变这一点.

                  Libraries should go last (at least after source and object files). You can't really change that.

                  -l 最好粘合到库名:

                   g++ -Wall main.cpp -o main -lOpenCL
                   #                          ^^^ glue the -l to the library name
                  

                  您可能还想将 -g(除了 -Wall)传递给编译器以获得可调试的二进制文件.使用 gdb 调试器.

                  You probably want to also pass -g (in addition of -Wall) to the compiler to get a debuggable binary. Use the gdb debugger.

                  正如 James Kanze 评论的那样,您可能想要替换 -g 使用 -ggdb 如果专门使用 gdb.

                  As James Kanze commented, you might want to replace -g with -ggdb if using specifically gdb.

                  这篇关于编译器标志的位置 -l的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                  How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                  Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                  Delay Loading DLLs(延迟加载 DLL)
                  Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                  Loading a dll from a dll?(从 dll 加载 dll?)

                    • <legend id='sYhjB'><style id='sYhjB'><dir id='sYhjB'><q id='sYhjB'></q></dir></style></legend>
                      <tfoot id='sYhjB'></tfoot>

                        <small id='sYhjB'></small><noframes id='sYhjB'>

                          <bdo id='sYhjB'></bdo><ul id='sYhjB'></ul>
                            <tbody id='sYhjB'></tbody>

                        • <i id='sYhjB'><tr id='sYhjB'><dt id='sYhjB'><q id='sYhjB'><span id='sYhjB'><b id='sYhjB'><form id='sYhjB'><ins id='sYhjB'></ins><ul id='sYhjB'></ul><sub id='sYhjB'></sub></form><legend id='sYhjB'></legend><bdo id='sYhjB'><pre id='sYhjB'><center id='sYhjB'></center></pre></bdo></b><th id='sYhjB'></th></span></q></dt></tr></i><div id='sYhjB'><tfoot id='sYhjB'></tfoot><dl id='sYhjB'><fieldset id='sYhjB'></fieldset></dl></div>