![]() |
|
| |
![]() |
#1 |
高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
![]() |
![]() compile with visual c++ 2005 express?
compile with visual c++ 2005 express? is it possible to compile and link using ms visual c++ 2005 express edition? i have a small utility that i need to port from linux to windows. i downloaded the express program, sp1, and windows platform sdk, but i'm not having much luck. the examples will generally compile, but linking is a problem. typical errors look like this: code: exhostappservices.obj : error lnk2019: unresolved external symbol __imp__regenumvaluew@32 referenced in function "public: virtual bool __thiscall exhostappservices::ttffilenamebydescriptor(class odttfdescriptor const &,class odstring &)" (?ttffilenamebydescriptor@exhostappservices@@uae_nabvodttfdescriptor@@aavodstring@@@z) dd_vc8md_gi.lib(odtruetypefont.obj) : error lnk2001: unresolved external symbol __imp__regenumvaluew@32 exhostappservices.obj : error lnk2019: unresolved external symbol __imp__regclosekey@4 referenced in function "public: virtual bool __thiscall exhostappservices::ttffilenamebydescriptor(class odttfdescriptor const &,class odstring &)" (?ttffilenamebydescriptor@exhostappservices@@uae_nabvodttfdescriptor@@aavodstring@@@z) dd_vc8md_gi.lib(odtruetypefont.obj) : error lnk2001: unresolved external symbol __imp__regclosekey@4 thanks, mark add "advapi32.lib" to the libraries list. vladimir do you mean the setting for options>vc++ directories? if so, then c:\program files\microsoft platform sdk\lib is already listed there and advapi32.dll is in that directory. now that i study it some more, i think i could use some help setting up the vc++ directories. currently i have the following references to oda files: library files: d:\oda\lib\vc8mt d:\oda\lib\vc8md should i also put the debug directories in there? do i need to list the exe directory or the include directory anywhere? what is the difference between the mt and md? obviously, i'm not familiar with the windows interface. if you can help me get configured so the examples will build, i'll be able to learn more as i go along. thanks very much, mark you can either add the lib directly in the project settings, or in code you can: code: #pragma comment(lib, 'advapi32.lib') // requires registry api functions in your code. personally, i set the folders for the libs in the project settings, but i use pragma's in code to know which libs i require. fair warning, i believe they are ms/windows specific, so if you intended to make cross platform compilable code you would either #define them out or have them in the project settings... as far as... code: library files: d:\oda\lib\vc8mt d:\oda\lib\vc8md you should only have one directory in there, dependent on your project settings.. what i have done, again as windows specific is.. code: //////////////////////////////////////////////////////////////////////////// // for cleaner/easier code, we turn some warnings into errors. all of these // errors can be avoided by properly written code //////////////////////////////////////////////////////////////////////////// // disable warnings caused by stl #pragma warning(disable : 4786) // identifier was truncated to 'number' characters in the debug information // convert certain deadly warnings to errors #pragma warning(error : 4002) // too many actual parameters for macro 'identifier' #pragma warning(error : 4003) // not enough actual parameters for macro 'identifier' #pragma warning(error : 4004) // incorrect construction after 'defined' #pragma warning(error : 4006) // #undef expected an identifier #pragma warning(error : 4009) // string too big; trailing characters truncated #pragma warning(error : 4015) // 'identifier' : type of bit field must be integral #pragma warning(error : 4033) // 'function' must return a value #pragma warning(error : 4035) // 'function' : no return value #pragma warning(error : 4045) // 'identifier' : array bounds overflow #pragma warning(error : 4053) // one void operand for '?:' #pragma warning(error : 4054) // 'conversion' : from function pointer 'type1' to data pointer 'type2' #pragma warning(error : 4059) // pascal string too big, length byte is length % 256 #pragma warning(error : 4063) // case 'identifier' is not a valid value for switch of enum 'identifier' #pragma warning(error : 4064) // switch of incomplete enum 'identifier' #pragma warning(error : 4078) // case constant 'value' too big for the type of the switch expression #pragma warning(error : 4087) // 'function' : declared with 'void' parameter list #pragma warning(error : 4098) // 'function' : void function returning a value #pragma warning(error : 4390) // ';' : empty controlled statement found; is this the intent? #pragma warning(error : 4541) // rtti train wreck #pragma warning(error : 4706) // assignment in conditional #pragma warning(error : 4715) // not all control paths return a value #pragma warning(error : 4013) // function undefined; assuming extern returning int #pragma warning(error : 4553) // '==' : operator has no effect; did you intend '='? #pragma warning(error : 4551) // function call missing argument list //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // macros for emitting compiler messages //////////////////////////////////////////////////////////////////////////// // debugging trick, outputs to do messages during compile time // one can double click the output to jump to the source line #ifndef __todo__ #define __str2__(x) #x #define __str1__(x) __str2__(x) #define __todo__ __file__ "("__str1__(__line__)") : to do: " #endif // another message #ifndef __compile_option__ #define __str2__(x) #x #define __str1__(x) __str2__(x) #define __compile_option__ __file__ "("__str1__(__line__)") : compile option: " #endif // another message #ifndef __quirk__ #define __str2__(x) #x #define __str1__(x) __str2__(x) #define __quirk__ __file__ "("__str1__(__line__)") : quirk: " #endif //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// // macro to determine which runtime is being used. useful for only having // to do a single #ifdef compare for each lib we link to //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// #if defined(_debug)&&defined(_mt)&&defined(_dll)// msvcrtd, /mdd #define msvcrtd //debug dynamic link (dll) #pragma message(__compile_option__ "debug dynamic link (dll)") #elif defined(_debug)&&defined(_mt)// libcmtd, /mtd #define libcmtd //debug static multithread #pragma message(__compile_option__ "debug static multithread") #elif defined(_mt)&&defined(_dll)// msvcrt, /md #define msvcrt //dynamic link (dll) #pragma message(__compile_option__ "dynamic link (dll)") #elif defined(_mt)// libcmt, /mt #define libcmt //static multithread #pragma message(__compile_option__ "static multithread") #else #pragma warning("not using /mt, /mtd, /md, or /mdd!") #endif in a common header.. and then in my code i can do.. code: #if !defined(_toolkit_in_dll_) #if defined(msvcrtd)||defined(msvcrt)// /mdd | /md //#pragma comment(linker, "-verbose") #pragma comment(lib,"dd_vc8md_br") // depend of exploding geometry #if !defined(use_custom_new_delete) //#pragma comment(lib,"dd_vc8md_alloc.lib") // don't need this, as we have our own stubs //#pragma comment(lib,"dd_alloc_dll.lib") // don't need this, as we have our own stubs #endif #pragma comment(lib,"dd_vc8md_gi.lib") #pragma comment(lib,"dd_vc8md_acisrenderer.lib") // depend of exploding geometry #pragma comment(lib,"dd_vc8md_acisbuilder.lib") // depend of exploding geometry #pragma comment(lib,"dd_vc8md_modelergeometry.lib") // for exploding geometry #pragma comment(lib,"dd_vc8md_db.lib") #pragma comment(lib,"dd_vc8md_ge.lib") #pragma comment(lib,"dd_vc8md_gs.lib") #pragma comment(lib,"dd_vc8md_plotsettingsvalidator.lib") #pragma comment(lib,"dd_vc8md_root.lib") #pragma comment(lib,"dd_vc8md_spatialindex.lib") #pragma comment(lib,"dd_vc8md_recomputedimblock.lib") #elif defined(libcmtd)||defined(libcmt) // /mtd || /mt // mt option! #pragma comment(lib,"dd_vc8mt_br") // depend of exploding geometry #if !defined(use_custom_new_delete) //#pragma comment(lib,"dd_vc8mt_alloc.lib") // don't need this, as we have our own stubs //#pragma comment(lib,"dd_alloc_dll.lib") // don't need this, as we have our own stubs #endif #pragma comment(lib,"dd_vc8mt_gi.lib") #pragma comment(lib,"dd_vc8mt_acisrenderer.lib") // depend of exploding geometry #pragma comment(lib,"dd_vc8mt_acisbuilder.lib") // depend of exploding geometry #pragma comment(lib,"dd_vc8mt_modelergeometry.lib") // for exploding geometry #pragma comment(lib,"dd_vc8mt_db.lib") #pragma comment(lib,"dd_vc8mt_ge.lib") #pragma comment(lib,"dd_vc8mt_gs.lib") #pragma comment(lib,"dd_vc8mt_plotsettingsvalidator.lib") #pragma comment(lib,"dd_vc8mt_root.lib") #pragma comment(lib,"dd_vc8mt_spatialindex.lib") #pragma comment(lib,"dd_vc8mt_recomputedimblock.lib") #else #pragma error("_md[d] or _mt[d] must be defined!") #endif #else // if we want opendesign to be external dll's #pragma comment(lib,"dd_br_dll") // depend of exploding geometry #if !defined(use_custom_new_delete) #pragma comment(lib,"dd_alloc_dll.lib") // don't need this, as we have our own stubs //#pragma comment(lib,"dd_alloc_dll.lib") // don't need this, as we have our own stubs #endif #pragma comment(lib,"dd_gi_dll.lib") #pragma comment(lib,"dd_acisrenderer_dll.lib") // depend of exploding geometry #pragma comment(lib,"dd_acisbuilder_dll.lib") // depend of exploding geometry #pragma comment(lib,"dd_modelergeometry_dll.lib") // for exploding geometry #pragma comment(lib,"dd_db_dll.lib") #pragma comment(lib,"dd_ge_dll.lib") #pragma comment(lib,"dd_gs_dll.lib") #pragma comment(lib,"dd_plotsettingsvalidator_dll.lib") #pragma comment(lib,"dd_root_dll.lib") #pragma comment(lib,"dd_spatialindex_dll.lib") //#pragma comment(lib,"dd_vc8md_rxrasterservices.lib") //#pragma comment(lib,"dd_vc8md_rxrasterprocessor.lib") #pragma comment(lib,"dd_vc8md_recomputedimblock.lib") //#pragma comment(lib, "dd_vc8md_dummyrecomputedimblock.lib") //dd_vc8mt_recomputedimblock.lib //#pragma comment(lib,"gs_winbitmap.lib") //#pragma comment(lib,"dd_vc8md_ave.lib")- //#pragma comment(lib,"dd_vc8md_exfieldevaluator.lib") #endif then all you need to worry about is having the appropriate lib path per project configuration. you may (and, perhaps, should) use ready project files for compiling examples. then, having a working example, you may fix your project accordingly. static md configuration: \projectfiles\win32\msvc8\allexamples.sln. dll configuration: \projectfiles\win32\msvc8\allexamplesdll.sln. md/mt differ in the c runtime usage (dynamc vs. static runtime) (using #pragma(lib), as suggested above, is ... questionable) vladimir so i edited the vc++ directories so there is a reference to vc8mt but not vc8md. then i loaded the allexamples.sln and tried to build odreadex from there. but i still have the link errors: code: ------ rebuild all started: project: odreadex, configuration: release win32 ------ deleting intermediate and output files for project 'odreadex', configuration 'release|win32' compiling... tostring.cpp odfilebuf.cpp exundocontroller.cpp exsystemservices.cpp exhostappservices.cpp exgirasterimage.cpp generating code... compiling... odreadex.cpp compiling password support for r18 drawings giworlddrawdumper.cpp exprotocolextension.cpp dbdumper.cpp generating code... linking... creating library ../../../../../exe/vc8/release/odreadex.lib and object ../../../../../exe/vc8/release/odreadex.exp exhostappservices.obj : error lnk2019: unresolved external symbol __imp__regenumvaluew@32 referenced in function "public: virtual bool __thiscall exhostappservices::ttffilenamebydescriptor(class odttfdescriptor const &,class odstring &)" (?ttffilenamebydescriptor@exhostappservices@@uae_nabvodttfdescriptor@@aavodstring@@@z) dd_vc8md_gi.lib(odtruetypefont.obj) : error lnk2001: unresolved external symbol __imp__regenumvaluew@32 exhostappservices.obj : error lnk2019: unresolved external symbol __imp__regclosekey@4 referenced in function "public: virtual bool __thiscall exhostappservices::ttffilenamebydescriptor(class odttfdescriptor const &,class odstring &)" (?ttffilenamebydescriptor@exhostappservices@@uae_nabvodttfdescriptor@@aavodstring@@@z) dd_vc8md_gi.lib(odtruetypefont.obj) : error lnk2001: unresolved external symbol __imp__regclosekey@4 exhostap etc etc etc i get similar results if i build the entire allexamples. mark that's queer. anyway, add the library advapi32.lib to the libraries list: "project properties" > linker > additional dependencies vladimir that improved things a lot! now there are only 3 remaining unresolved externals: code: ------ rebuild all started: project: odreadex, configuration: debug win32 ------ deleting intermediate and output files for project 'odreadex', configuration 'debug|win32' compiling... tostring.cpp odreadex.cpp compiling password support for r18 drawings giworlddrawdumper.cpp exprotocolextension.cpp dbdumper.cpp odfilebuf.cpp exundocontroller.cpp exsystemservices.cpp exhostappservices.cpp exgirasterimage.cpp generating code... linking... creating library ../../../../../exe/vc8/debug/odreadex.lib and object ../../../../../exe/vc8/debug/odreadex.exp dd_vc8md_root.lib(rxinit.obj) : error lnk2019: unresolved external symbol __imp__cotaskmemfree@4 referenced in function "public: virtual class odstring __thiscall odrxsystemservices::createguid(void)" (?createguid@odrxsystemservices@@uae?avodstring@@xz) dd_vc8md_root.lib(rxinit.obj) : error lnk2019: unresolved external symbol __imp__stringfromclsid@8 referenced in function "public: virtual class odstring __thiscall odrxsystemservices::createguid(void)" (?createguid@odrxsystemservices@@uae?avodstring@@xz) dd_vc8md_root.lib(rxinit.obj) : error lnk2019: unresolved external symbol __imp__cocreateguid@4 referenced in function "public: virtual class odstring __thiscall odrxsystemservices::createguid(void)" (?createguid@odrxsystemservices@@uae?avodstring@@xz) ../../../../../exe/vc8/debug/odreadex.exe : fatal error lnk1120: 3 unresolved externals creating browse information file... microsoft browse information maintenance utility version 8.00.50727 copyright (c) microsoft corporation. all rights reserved. build log was saved at "file://d:\oda\out\vc8\odreadex_debug\buildlog.htm" odreadex - 4 error(s), 0 warning(s) ========== rebuild all: 0 succeeded, 1 failed, 0 skipped ========== thanks again, mark add also ole32.lib vladimir success! thank you very much! mark |
![]() |
![]() |
GDT自动化论坛(仅游客可见) |
主题工具 | 搜索本主题 |
显示模式 | |
|
|
![]() |
||||
主题 | 主题发起者 | 论坛 | 回复 | 最后发表 |
【转帖】《viaul basic .net二次开发autocad范例精解》哪有下载 | yang686526 | 数据库ObjectDBX | 0 | 2009-04-28 10:35 AM |
《viaul basic .net二次开发autocad范例精解》哪有下载 | yang686526 | ObjectARX(AutoLISP) | 0 | 2009-04-26 03:49 PM |
【转帖】vb express 2008 addin template | yang686526 | SolidWorks二次开发 | 0 | 2009-04-13 03:14 PM |