翻译CL.EXE到MinGW的命令
问题描述:
我有这个CL.EXE命令翻译CL.EXE到MinGW的命令
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 [email protected]: symbol not defined
,或者通过猜测
-Error: invalid Suffix
-Warning: ‘somevariable’ initialized and declared ‘extern’
如果你能帮助我改变命令时,请这样做。谢谢。
答
从函数在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
你应该看看[gcc命令行参考](https://gcc.gnu.org/onlinedocs/gcc-7.1.0/ GCC /#TOC-GCC-命令选项)。 – VTT