从32bit迁移到64bit[3]
>> *.lib文件总是无法生成
Symptom:
一个新生成的DLL始终没有*.lib文件生成。
Solution:
原因是没有Symbol导出,要么显式指定一个*.def文件,要么就需要“__declspec(dllexport)”
所以需要SMCP_DLL or 使用*.def file
-----------------------------------------------------------------
#ifdef SMCP_DLL
#ifdef SMCPDECL_APP_QTWIDGETS
#define EXPORT_APP_QTWIDGETS __declspec(dllexport)
#else
#define EXPORT_APP_QTWIDGETS __declspec(dllimport)
#endif
#else
#define EXPORT_APP_QTWIDGETS
#endif
-----------------------------------------------------------------
In the Linker -> Advanced property tab of the DLL project, verify that the value for Import Library (the .lib file you are looking for) is correct/reasonable. The value of this property will determine what the import library is named, and where the linker will write it to.
You may also need to generate an imports definition file (.def) in your project, or check your header files and make sure your exported functions are tagged with the __declspec(dllexport) qualifier in the header file. This is usually toggled by a #define such as:
#ifdef MYAPI_EXPORTS #define MYAPI_API __declspec(dllexport) #else #define MYAPI_API __declspec(dllimport) #endif void MYAPI_API foo(int bar);
Basically you want the compiler to see dllexport when it is building the library, but dllimport when your client code is #including the header file. If Visual Studio generated the basic project structure, it probably already created a suitable #define to use.
You do not have to both create the .def file and add the dllexport, just one or the other. I prefer the latter. Also, if you choose to use a .def file, you need to specify it in the Linker properties of your library project.
>> Targe Machine should be changed
正确设置"Target Machine": MachineX64 (/MACHINE:X64)
>> Materials
Optimization of 64 bit programs
http://www.codeproject.com/Articles/33565/Optimization-of-64-bit-programs
20 issues of porting C++ code on the 64-bit platform
http://www.codeproject.com/Articles/18855/20-issues-of-porting-C-code-on-the-64-bit-platform
Lessons on development of 64-bit C/C++ applications
http://www.codeproject.com/Articles/359970/Lessons-on-development-of-64-bit-C-Cplusplus-appli