【问题标题】:Translate CL.exe to mingw command将 CL.exe 翻译成 mingw 命令
【发布时间】:2017-07-02 09:36:46
【问题描述】:

我有这个 CL.exe 命令

cl -Fesample.dll -Oi -LD -D NO_TRACE=1 -MT sample.cpp sample_dll.def

我想用 MinGW 在 Linux 上编译它,这就是我目前所拥有的

i586-mingw32msvc-gcc -Fesample.dll -shared -D NO_TRACE=1 sample.cpp sample_dll.def

跟踪 cl 命令选项

-Oi is optimisation -> not important at this point
-LD is for generating a dll -> replaced with -shared
-D is for setting a constant in the source -> same on both
-MT is for multithreading -> i was not able to find the mingw option for this as it seems it is not fully supported.

我错了吗?

但它不会编译,我真的不知道为什么。 我从测试中得到的错误是以太

-Cannot export samplefunction@4: symbol not defined

或者通过猜测改变命令时

-Error: invalid Suffix
-Warning: ‘somevariable’ initialized and declared ‘extern’

如果你能帮助我,请这样做。谢谢。

【问题讨论】:

标签: c++ windows gcc compilation mingw


【解决方案1】:

从 C++ 代码文件中的函数编译共享库:

 g++ -o esample.so -shared -fpic -DNO_TRACE=1 sample.cpp

如今,多线程 (-MT) 应该是默认设置。

-LD 等效于 -fpic-shared

参考:http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html

【讨论】:

    猜你喜欢
    • 2017-12-20
    • 1970-01-01
    • 2021-11-04
    • 1970-01-01
    • 1970-01-01
    • 2018-04-09
    • 2017-06-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多