[gambit-list] Visual Studio and C++ FFI

Valery Valery valery at digitalchile.net
Sun Sep 27 16:18:33 EDT 2009


Still can't compile C++ FFI example by cl.exe

The example from page
http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Compiling_Gambit_software_for_different_target_environments
compiled successful. I have change it.

<<<foo.cpp>>>
int cpp_bar(char* text) {
   return 0;
}

<<<foo.h>>>
#ifdef __cplusplus
extern "C" {
#endif
int cpp_bar(char* text);
#ifdef __cplusplus
}
#endif

<<<foo-main.scm>>>
(c-declare #<<end-of-c-declare
#include "foo.h"
end-of-c-declare
)
(define bar (c-lambda (char-string) int "cpp_bar"))


Then compile it:
gsc -link foo-main
cl -Fefoo-main.exe -nologo -Oityb1 -MT -D_CRT_SECURE_NO_DEPRECATE -c
-I"C:\gambc\include" -I"C:\gambc\lib" -D___SINGLE_HOST -D_WINDOWS
"foo.cpp" "foo-main_.c" "foo-main.c"
cl -Fefoo-main.exe foo.obj foo-main.obj foo-main_.obj
C:\gambc\lib\libgambc.lib Kernel32.Lib User32.Lib Gdi32.Lib WS2_32.Lib
/link /subsystem:windows

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.
/out:foo-main.exe
/subsystem:windows
foo.obj
foo-main.obj
foo-main_.obj
C:\gambc\lib\libgambc.lib
Kernel32.Lib
User32.Lib
Gdi32.Lib
WS2_32.Lib
foo-main.obj : error LNK2019: unresolved external symbol _cpp_bar referenced in
function ____H__20_foo_2d_main
foo-main.exe : fatal error LNK1120: 1 unresolved externals

What is wrong here?
Does anybody know where I can get workable example of C++FFI under windows?
Could be great if the wiki will have some examples  how to build and
app with C++ FFI under different platforms.



More information about the Gambit-list mailing list