Hello
I checked
my MyDLL2.dll with matlab.
myPath = 'C:\CPLUSPLUS\MyDLL2\Debug';
hfile = 'C:\CPLUSPLUS\MyDLL2\MyDLL2.h';
loadlibrary([myPath '/MyDLL2'],hfile);
Agent=calllib('MyDLL2','TWUsetUserAgent','Hello');
sprintf('User: (%-s)', Agent)
unloadlibrary('MyDLL2');
dll is ok.
>>
userAgent
ans =
User:
(Hello)
And to
check on octave 3..0.2
I renamed mydll2.dll
to mydll2.dll.a to check my command
mkoctfile
TWUsetUserAgent.cc -LC:\CPLUSPLUS\MyDLL2\Debug -lMyDLL2
it build TWUsetUserAgent.oct file but it naturaly can
not runnig.
Then my
command is ok.
to solve
this problem i think,
i need to
install octave 3.0.3 for windows
But my question
is, how can i use und call mkoctfile in octave 3.0.3
Best regards
--- Michael Goffioul <address@hidden> schrieb am Di, 20.1.2009:
Von: Michael Goffioul <address@hidden> Betreff: Re: mkoctfile problem An: "Allahyari Rahim" <address@hidden> CC: address@hidden Datum: Dienstag, 20. Januar 2009, 15:37
You cannot link in a DLL directly. You need an import library file for that. This library file defines which symbols are exported by the corresponding library. Under MSVC, it would be called MyDLL2.lib and it is generated automatically by MSVC when creating the DLL if there are some exported symbols. Under MinGW, it would be called libMyDLL2.dll.a and it is created if you add the correct flags to the link command when creating the DLL (note that the "lib" prefix is required if you plan to use it at link
stage with -lMyDLL2).
If you have such import library file and it still does not work, you should check whether your DLL actually export the symbol you want to use. A good tool for that is depends.exe (Dependency viewer), which is available freely on the web.
Michael.
On Tue, Jan 20, 2009 at 2:22 PM, Allahyari Rahim <address@hidden> wrote: > i have same problem. > >> mkoctfile TWUsetUserAgent.cc -LC:\CPLUSPLUS\MyDLL2\Debug -lMyDLL2 > TWUsetUserAgent.o:TWUsetUserAgent.cc:(.text+0x4d6): undefined reference to > `_TWUsetUserAgent' > collect2: ld returned 1 exit status > octave-3.0.2.exe:23:C:\Programme\Octave\3.0.2_gcc-4.3.0\bin > > i build another library name MyDLL2.dll > > i send it to you to check that. > > best regards > > --- Michael Goffioul <address@hidden> schrieb am
Di, 20.1.2009: > > Von: Michael Goffioul <address@hidden> > Betreff: Re: mkoctfile problem > An: address@hidden > CC: address@hidden > Datum: Dienstag, 20. Januar 2009, 13:35 > > On Tue, Jan 20, 2009 at 12:19 PM, Allahyari Rahim <address@hidden> > wrote: >> what do you main with >> >> >> >> "If this does not > work, then copy > C:\TWUClib\lib\TWUClib.a into >> C:\TWUClib\lib\libTWUClib.a " > > Nothing more than what's stated: just copy the file using another > name. This is required, because when you specify a link flag as > -lmylibname, the compiler will look for a library file named > libmylibname.a (or libmylibname.so under UNIX and libmylibname.dll.a > under MinGW, but that's another story). > > >> but I did
so >> >> >> >>> mkoctfile TWUsetUserAgent.cc -LC:\TWUClib\lib -TWUClib.a > > The last element should be: -lTWUClib > > May I kindly suggest you to read some documentation about > compiler and compilation commands. I think that could help you > understand what's going on. mkoctfile is simply a wrapper around > an actual compiler. Most compilation flags are passed as-is to > the compiler/linker. What happened in the command above is that > used -TWUClib.a instead of -lTWUClib. This flag was passed > to the > linker and if you look at the linker help (man ld), you'll see that -T > is a valid option specifying a linker script. So the linker looked for > a script named WUClib.a and fails to find it. > > Michael. > >
|