Boost logo

Boost-Build :

From: mronion13 (cam_at_[hidden])
Date: 2004-02-26 18:38:53


> I understand what you are attempting to do.. But AFAIK there is no
way to do
> that in Windows.

It seems to work fine (maybe you aren't understanding exactly what I'm
doing? I'm not sure). I will give you the source for my simplistic
example (it models my real project which is, of course, more complex).

// main_core.cpp
__declspec(dllexport) int main_core_func( int x )
{
return x*x;
}

// main_prog.cpp
#include <windows.h>
#include <stdio.h>

__declspec(dllimport) extern int main_core_func( int x );
__declspec(dllexport) int main_prog_callback();

int main_prog_callback()
{
return 3;
}

int main( )
{
HMODULE handle = LoadLibrary( "plugin_1" );
if( handle == NULL ) { printf("Failed to load plugin_1"); return 1; }
void * vptr = (void*) GetProcAddress( handle, "plugin_1_func" );
if( vptr == NULL ) { printf("Failed to plugin_1_func"); return 1; }
int (*plugin_1_func)() = (int(*)()) vptr;
printf( "value: %d", main_core_func( plugin_1_func() ) );
return 0;
}

// plugin_1.cpp
__declspec(dllimport) extern int main_core_func( int x );
__declspec(dllimport) extern int main_prog_callback( );

#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) int plugin_1_func()
{
return main_core_func( main_prog_callback() );
}
#ifdef __cplusplus
}
#endif

If you build this with bjam and run the executable, it outputs
'value: 81' just as expected.

> ..If you do know better and are actually producing a link library
for the
> EXE.. One possible way to link to it is to use the <library-file>
feature to
> link to it as an external library.

It seems that BBv1 is producing import libraries for all executables
(exec_name.lib) in the same directory as the executable itself.
Actually, I think VC++ is the one making the .lib files; I think it
does this if you __declspec(dllexport) any symbols from an EXE.

> Possibly as such:
>
> dll plugin_1
> : <dll>main_core
> :
<debug><library-file>bin/main_proj/main_prog.exe/vc7/debug/main_prog.lib
> ;
>
> ..or something like that.

That didn't seem to work. It didn't add the right '/LIBPATH' to the
LINK command. It works fine using the combo <library-path> and
<find-library> (using BBv1, ver. 1.31.0 and VC++ ver. 7 (not 7.1)).

-Andy

 


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk