查看单个帖子
旧 2009-05-06, 06:32 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】newbie question9s0 code compiles, but cannot link

newbie question(s): code compiles, but cannot link
newbie question(s): code compiles, but cannot link
so i'm trying to get dwgdirect up 'n running, and i'm having some problems.
i've been looking at the odreadex example, which by the way compiles and links without problems on my computer.
then i thougt i'd have a go and try opening a file in my own project, which didn't go to well.
i included all the libs and files in exservices that the debug-mt configuration of the odreadex had.
here is the code:
php code:
#include "odacommon.h"
#include "exservices\exsystemservices.h"
#include "exservices\exhostappservices.h"
void testopenfff">(const fff">char fff">* fff">sfilenamefff">)
{
fff">odstreambufptr pbuffff">;
fff">odstaticrxobjectfff"><fff">exsystemservicesfff">> fff">testfff">;
fff">odinitializefff">(&fff">testfff">);
fff">pbuf fff">= fff">testfff">.fff">createfilefff">(fff">sfilenamefff">, fff">odafff">::fff">kfilereadfff">, fff">odafff">::fff">ksharedenynofff">, fff">odafff">::fff">kopenexistingfff">);
if(fff">pbuffff">.fff">isnullfff">())
fff">printffff">(fff">"file did not open"fff">);
else
fff">printffff">(fff">"file opened ok"fff">);
}
fff">
so what do i need to do get my simple code to link?
i've seen in the documentation and in the example that i probably need to add some of the macros defined in dwgdirect, such as:
code:
#ifndef _toolkit_in_dll_
// declare the entry point function for the custom module (one for each module).
odrx_declare_static_module_entry_point(customobjectsmodule);
odrx_declare_static_module_entry_point(modelermodule);
odrx_begin_static_module_map()
odrx_define_static_application("excustobjs", customobjectsmodule)
odrx_define_static_application("modelergeometry", modelermodule)
odrx_end_static_module_map()
#endifdon't know if this is what causes my problems though, the linker in vc2005 tells me that there are conflicts with libcmtd.lib and msvcrtd.lib
code:
msvcprtd.lib(msvcp80d.dll) : error lnk2005: "public: __thiscall std::_container_base::_container_base(void)" (??0_container_base@std@@qae@xz) already defined in dd_vc8mt_db.lib(dbdatabase1.obj)
libcmtd.lib(setlocal.obj) : error lnk2005: __configthreadlocale already defined in msvcrtd.lib(msvcr80d.dll)i'll attach an error log.
...so i'll be trying to figure this out myself, but any help would be greatly appreciated
attached files
double check the examples because they provide the correct odrx headers:
code:
#ifndef _toolkit_in_dll_
odrx_declare_static_module_entry_point(oddgnmodule);
odrx_declare_static_module_entry_point(oddwgmodule);
odrx_begin_static_module_map()
odrx_define_static_application(_t("dg_db.drx"), oddgnmodule)
odrx_define_static_application(_t("dd_db.dll"), oddwgmodule)
odrx_end_static_module_map()
#endifthat is what i use but it varies for all of us and depend on dll/static etc etc etc..
you also need something like this:
code:
odrx_init_static_module_map();
odrxinitialize(this);
:drxdynamiclinker()->loadmodule(_t("dg_db.drx"), false);
:drxdynamiclinker()->loadmodule(_t("dd_db.dll"), false);rather than your odinitialize... i think ....
last edited by andrew.truckle@cartosurveys.co.uk; 19th june 2008 at 07:27 amfff">.
quote:
originally posted by ajtruckle
double check the examples because they provide the correct odrx headers:
code:
#ifndef _toolkit_in_dll_
odrx_declare_static_module_entry_point(oddgnmodule);
odrx_declare_static_module_entry_point(oddwgmodule);
odrx_begin_static_module_map()
odrx_define_static_application(_t("dg_db.drx"), oddgnmodule)
odrx_define_static_application(_t("dd_db.dll"), oddwgmodule)
odrx_end_static_module_map()
#endifthat is what i use but it varies for all of us and depend on dll/static etc etc etc..
you also need something like this:
code:
odrx_init_static_module_map();
odrxinitialize(this);
:drxdynamiclinker()->loadmodule(_t("dg_db.drx"), false);
:drxdynamiclinker()->loadmodule(_t("dd_db.dll"), false);rather than your odinitialize... i think ....
this is initialization for the app using both dgn and dd. it is not necessary for dwg only - simple initialization posted in the first message is enough.
vladimir
probably you mixed debug/release libraries. or maybe you are linking wrong crt.
vladimir
quote:
originally posted by wvk
this is initialization for the app using both dgn and dd. it is not necessary for dwg only - simple initialization posted in the first message is enough.
i realise that. i was simply offering what mine does. for example, his does not show the odwgmodule and his does not show the dynamic linkers in his code.
i think he is mixing dynamic dll module calls with static as you say.
thanks for the replies you two.
just to clear up some of what you've discussed:
1) i'm using exactly the same debug libs as the example does (dd_vc8dbg-lib-vc8mtd)
2) i'm trying to use static libs as wvk pointed out, don't want to use dll
so is there any of you guys who know what i need to ad to my simple test code, to get it to link?
by the way, wvk, what did you mean by "or maybe you are linking wrong crt"?
last edited by oraly; 20th june 2008 at 12:52 amfff">. reason: added a question at the end
edited my code a bit, does it seem right now?
php code:
#include "odacommon.h"
#include "exservices\exsystemservices.h"
#include "exservices\exhostappservices.h"
#include "exservices\odfilebuf.h"
#include "rxdynamicmodule.h"
/************************************************************************/
/* define a module map for statically linked modules: */
/************************************************************************/
#ifndef _toolkit_in_dll_
odrx_declare_static_module_entry_pointfff">(fff">modelermodulefff">);
odrx_declare_static_module_entry_pointfff">(fff">odrecomputedimblockmodulefff">);
odrx_begin_static_module_mapfff">()
fff">odrx_define_static_applicationfff">(fff">dd_tfff">(fff">"modelergeometry"fff">), fff">modelermodulefff">)
fff">odrx_define_static_applicationfff">(fff">dd_tfff">(fff">"recomputedimblock"fff">), fff">odrecomputedimblockmodulefff">)
odrx_end_static_module_mapfff">()
#endif
void testopenfff">(const fff">char fff">* fff">sfilenamefff">)
{
#ifndef _toolkit_in_dll_
fff">odrx_init_static_module_mapfff">();
#endif
fff">odstreambufptr pbuffff">;
fff">odstaticrxobjectfff"><fff">exsystemservicesfff">> fff">testfff">;
fff">odinitializefff">(&fff">testfff">);
fff">pbuf fff">= fff">testfff">.fff">createfilefff">(fff">sfilenamefff">, fff">odafff">::fff">kfilereadfff">, fff">odafff">::fff">ksharedenynofff">, fff">odafff">::fff">kopenexistingfff">);
if(fff">pbuffff">.fff">isnullfff">())
fff">printffff">(fff">"file did not open"fff">);
else
fff">printffff">(fff">"file opened ok"fff">);
}
fff">
still it compiles without errors, but cannot link.
since you said you are using the mtd libraries, are you actually using the "debug" build of your project? if you are using mtd with a "release" build it is wrong. "mt" libraries for release build. mtd for debug.
yes i'm certain of that i'm using debug libs, tripple checked it.
i'm down to only one error message now:
code:
libcmtd.lib(crt0.obj) : error lnk2019: unresolved external symbol _main referenced in function ___tmaincrtstartupi'll be checking all projects settings in vc2005 to see if it could be some configuration that's causing the error.
btw, i changed code generation from "multi-threaded dll (/md)" to "multi-threaded debug (/mtd)", which made a lot of erros go away
...ooups, major bummer on my behalf
problem solved
a bit embarrassed after spending about a days work on this. i'll have to admit the solution was simple and caused by forgetting some basic c sfuff
adding a bit of code to run my function was all i needed to add at the en of my file:
php code:
int mainfff">(fff">int argcfff">, fff">charfff">* fff">argvfff">[])
{
if (fff">argc fff"><fff">2fff">)
{
fff">printffff">(fff">"not enough arguments"fff">);
return fff">0fff">;
}
fff">testopenfff">(fff">argvfff">[fff">1fff">]);
return fff">1fff">;
}
fff">
you should always have a main function in any c program
...please don't laugh!!!
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)