- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在“Windows 7 64 位”命令提示符下使用 mingw 编译简单的 C++ 程序。我得到的错误是:
>gcc fs.cpp -lboost_filesystem -lboost_system
c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lboost_filesystem
c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lboost_system
collect2.exe: error: ld returned 1 exit status
可能有用的系统变量信息:
c:\Boost\lib>echo %path%
C:\Boost\boost-build\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Skype\Phone\;c:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin\;c:\Boost\lib\
c:\Boost\lib>echo %library_path%
c:\Boost\lib
c:\Boost\lib>echo %cplus_include_path%
c:\Boost\include\
boost/lib 的内容是:
c:\Boost\lib>dir
Volume in drive C is Acer
Volume Serial Number is 62C5-4B7E
Directory of c:\Boost\lib
13.06.2019. 00:31 <DIR> .
13.06.2019. 00:31 <DIR> ..
13.06.2019. 00:28 5.608.426 libboost_filesystem-mgw81-mt-d-x32-1_70
13.06.2019. 00:28 6.553.512 libboost_filesystem-mgw81-mt-d-x64-1_70
13.06.2019. 00:28 3.713.979 libboost_filesystem-mgw81-mt-d-x64-1_70
13.06.2019. 00:28 92.342 libboost_filesystem-mgw81-mt-d-x64-1_70
13.06.2019. 00:28 344.104 libboost_filesystem-mgw81-mt-s-x32-1_70
13.06.2019. 00:28 405.348 libboost_filesystem-mgw81-mt-s-x64-1_70
13.06.2019. 00:28 5.608.426 libboost_filesystem-mgw81-mt-sd-x32-1_7
13.06.2019. 00:28 6.553.512 libboost_filesystem-mgw81-mt-sd-x64-1_7
13.06.2019. 00:28 344.104 libboost_filesystem-mgw81-mt-x32-1_70.a
13.06.2019. 00:28 405.348 libboost_filesystem-mgw81-mt-x64-1_70.a
13.06.2019. 00:28 239.395 libboost_filesystem-mgw81-mt-x64-1_70.d
13.06.2019. 00:28 92.132 libboost_filesystem-mgw81-mt-x64-1_70.d
13.06.2019. 00:28 2.822 libboost_system-mgw81-mt-d-x32-1_70.a
13.06.2019. 00:28 3.118 libboost_system-mgw81-mt-d-x64-1_70.a
13.06.2019. 00:28 49.550 libboost_system-mgw81-mt-d-x64-1_70.dll
13.06.2019. 00:28 1.772 libboost_system-mgw81-mt-d-x64-1_70.dll
13.06.2019. 00:28 730 libboost_system-mgw81-mt-s-x32-1_70.a
13.06.2019. 00:28 924 libboost_system-mgw81-mt-s-x64-1_70.a
13.06.2019. 00:28 2.822 libboost_system-mgw81-mt-sd-x32-1_70.a
13.06.2019. 00:28 3.118 libboost_system-mgw81-mt-sd-x64-1_70.a
13.06.2019. 00:28 730 libboost_system-mgw81-mt-x32-1_70.a
13.06.2019. 00:28 924 libboost_system-mgw81-mt-x64-1_70.a
13.06.2019. 00:28 47.834 libboost_system-mgw81-mt-x64-1_70.dll
13.06.2019. 00:28 1.760 libboost_system-mgw81-mt-x64-1_70.dll.a
我尝试用
手动包含路径gcc fs.cpp -o fs.exe -Lc:\Boost\lib -lboost_filesystem -lboost_system
或与
gcc fs.cpp -o fs.exe -L c:\Boost\lib -lboost_filesystem -lboost_system
或与
gcc fs.cpp -o fs.exe -L c:\Boost\lib -llibboost_filesystem -llibboost_system
并得到相同的输出。
对我来说,这看起来像是链接器问题。但是,我没有经验。这可能是编译错误的库文件的结果吗?
在 Windows 上编译 c++ 时应该使用哪些选项?我哪里出错了?
最佳答案
我认为您的问题是由boost
库文件的复杂命名方案引起的,
见Boost Getting Started on Windows: library naming .
简而言之,boost
将字符附加到库文件名以指定(除其他事项外):
-mgw81
,-mt
,-x64
-1_70
。因此,boost_filesystem
变为:boost_filesystem-mgw81-mt-x64-1_70
而 boost_system
变为:boost_system-mgw81-mt -x64-1_70
,所以尝试:
gcc fs.cpp -o fs.exe -Lc:\Boost\lib -lboost_filesystem-mgw81-mt-x64-1_70 -lboost_system-mgw81-mt-x64-1_70
注意:构建类似 cmake 的系统简化这些问题,但它们可以引入新问题,请参阅:cmake FindBoost not finding Boost libraries when building with MinGW on Windows .
关于c++ -\mingw-w64\...\ld.exe : cannot find -lboost_filesystem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56571745/
我正在努力处理不同的 R 可执行文件。在批处理文件中运行命令行时,R.exe(带或不带 CMD BATCH 选项)、Rcmd.exe、Rscript.exe 和 Rterm.exe 有什么区别? 两者
这个问题是我之前问题的一个答案的扩展:how to save user registration in the exe... (C#) . 这个想法本身对我来说仍然很新,但它似乎是合理的。我第一次尝试
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 12 年前。 Improve thi
我正在使用 React VR 制作一个 WebVR 应用程序。我将使用 Oculus Rift 和 HTC-Vive 测试该应用程序。我正在使用浏览器 Firefox Nightly 来访问 WebV
当我从 A.exe(位于 c:/my_software/FOLDER_A/A.exe)运行 B.exe(位于 c:/my_software/FOLDER_B/B.exe)时,两者均使用 cx_Free
我有一个以前的程序员留下的exe(GUI),它是在cpp中完成的,但是我需要禁用程序中的一些键盘键,因为当它们被意外击中时,这是不可取的。我正在使用 Windows。 我能否编写一个程序来在 Wind
这不是以下 SO 问题的重复: How do I tell if a win32 application uses the .NET runtime . 如果给定的 exe 文件是 .net exe
我刚刚安装了 ActivePython 3.6 的 64 位版本,发现它包含三个可执行文件,它们报告相同的版本信息,大小相同,但不完全相同,即peer fc.exe。我有 python.exe pyt
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
有哪些方法可以保护exe文件免遭逆向工程。有很多打包工具可以打包exe文件。这种方法在http://c-madeeasy.blogspot.com/2011/07/protecting-your-c-
仅当应用“X”(Inspect.exe | Narrator.exe | Magnify.exe)正在运行时,我才能在 Windows 应用程序中获取一些 IUIAutomationElements。
我正在编写一个创建 Windows 服务的程序。所以我需要两个 .exe 文件——一个用于程序,创建服务,另一个用于服务本身。但是我想将这两个文件合二为一。我有以下想法 - 打开 .exe 文件,我想
我有一个 UWP 应用,我需要从 users %appdata% 文件夹中启动一个 .Exe 文件。 我不知道如何找到 %appdata% 或如何启动 Exe 文件。 我已经查看了所有解决方案,但没有
我最近安装了 Visual Studio 2017,MSBuild.exe 不是应该自带的吗? bash 脚本之一正在调用它,但找不到任何东西。 这是 build.bat 产生错误的部分(您可以看到整
我正在我自己的代码中尝试来自 Mad-collections(用于在 exe 中添加/删除或更新资源的单元)中 Madres 单元的不同功能。这适用于小型资源(小于 50 MB),但对于较大的资源(大
什么是PreEmptive Protection Dotfuscator exe文件的Map.Xml和Dotfuscator1.Xml文件。我应该出于某种原因保留它们,还是项目 exe 文件组装需要它
我最近接手了一个项目,我不确定最后一个人是如何调试这个的......我有两个可执行文件,一个最终运行另一个。我将它们称为 exe1 和 exe2。这些是用 C# 创建的,我使用 Visual Stud
如何从 REBOL 脚本创建 Windows 可执行文件 (.exe)?有任何说明或视频吗? 最佳答案 使用 Rebol 2 最简单的方法是使用 SDK - 尽管这需要花钱购买许可证。该方法称为封装。
我正在尝试打开下载的 .exe 文件,但它在打开后立即关闭。有什么可能的方法可以让我打开它更长的时间来阅读内容。 最佳答案 它可能是一个控制台应用程序而不是一个 GUI 应用程序。使用命令提示符运行
我想运行一个位于以下目录中的应用程序: C:\LCR 12\stu.exe 使用 AutoIt,运行上述 stu.exe 文件的代码是什么? 最佳答案 像这样: Run("C:\LCR 12\stu.
我是一名优秀的程序员,十分优秀!