From florian.burkart at gmail.com  Tue Nov 27 13:53:47 2012
From: florian.burkart at gmail.com (Florian Burkart)
Date: Tue, 27 Nov 2012 12:53:47 +0000
Subject: [Rd] Problems with MinGW and boost on Windows
Message-ID: <CAPSN_LWkjENv1Y4dSxG-73yGhTfYuewScwgKKEeUjbWp97jDfw@mail.gmail.com>

Hi,

I am not sure how widespread this problem is, but definitely occurs for me
on 64 bit Win 7 with a 64 bit R.

I think I have isolated the issue (to a certain extent) in the attached
Test.cpp file. Basically, I think linking with boost serialization is
causing the plugin to fail.

If I compile Test.cpp with line 43 (Dummy* Read() ...) commented out, I get
the expected output in R:

>
dyn.load("../MinGW/Debug64/Tester.dll",DLLpath="C:/Sys/boost/MinGW64/boost_1_50_0/lib")
Hello World.
> .Call("add",c(1,3))
[1] 4
> is.loaded("add")
[1] TRUE

However, if line 43 is uncommented, the output changes to

>
dyn.load("../MinGW/Debug64/Tester.dll",DLLpath="C:/Sys/boost/MinGW64/boost_1_50_0/lib")
Hello World.
> .Call("add",c(1,3))
Error in .Call("add", c(1, 3)) : C symbol name "add" not in load table
> is.loaded("add")
[1] FALSE

I am not sure what exactly is going wrong. This happens both if I link to
boost serialization statically or dynamically.

This is on R version R-2.15.1, and both boost serialization libraries and
the plugin are built with the gcc (4.6.3 20111208 prerelease) and make.exe
provided by RTools (Collection 2.16.0.1923) using the -m64 flag.

Build command was
g++  -c  "Test.cpp" -g -std=gnu++0x -m64 -O1 -DDEBUG  -o
obj/Debug64/Tester/Trunk_Test.o -I. -I/R/R-2.15.1/include
-I/R/R-2.15.1/library/Rcpp/include -I/Sys/boost/boost_1_50_0
g++ -shared -fPIC -o Debug64/Tester.dll @"MinGW\Tester.txt" -L.
-L/R/R-2.15.1/library/Rcpp/lib/x64 -L/R/R-2.15.1/bin/x64
-L/Sys/boost/MinGW64/boost_1_50_0/lib -LDebug64  -lRcpp -lR
 -lboost_serialization-mgw46-mt-d-1_50 -lboost_system-mgw46-mt-d-1_50
-Wl,--out-implib="Debug64/libTester.a" -m64

And for boost:
b2.exe --prefix=c:\Sys\boost\MinGW64\boost_1_50_0 toolset=gcc
address-model=64 link=static,shared -s BZIP2_SOURCE=C:\Sys\bzip2-1.0.6 -s
ZLIB_SOURCE=C:\Sys\zlib-1.2.7 install

Also note that this works fine on linux (Ubuntu).

I have been struggling to get past this for several weeks now... any help
would be greatly appreciated.

Thanks,
Florian


[Rd] Problems with MinGW and boost on Windows
Florian Burkart