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" {
__declspec(dllexport) int plugin_1_func()
return main_core_func( main_prog_callback() );
#ifdef __cplusplus

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
> :
> ;
> ..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)).



Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at