Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-compiling to Windows with MinGW #7

Closed
marlam opened this issue May 9, 2011 · 6 comments
Closed

Cross-compiling to Windows with MinGW #7

marlam opened this issue May 9, 2011 · 6 comments
Assignees
Labels

Comments

@marlam
Copy link
Contributor

marlam commented May 9, 2011

I'm trying to cross-compile Equalizer for Windows on Ubuntu, using Mingw-cross-env.

There are a few minor problems regarding upper-/lowercase, missing includes, and one clash of a variable name with some header definition. I have a patch that fixes these; I'll try to attach it to this issue (not sure yet how this works on github).

But now I'm stuck with a problem when linking libEqualizerServer:

Linking CXX shared library ../../bin/libEqualizerServer.dll
Creating library file: libEqualizerServer.dll.a
CMakeFiles/lib_EqualizerServer_shared.dir/objects.a(channel.cpp.obj):channel.cpp:(.text$ZN2eq6fabric7ChannelINS_6server6WindowENS2_7ChannelEEC2ERKS5[eq::fabric::Channel<eq::server::Window, eq::server::Channel>::Channel(eq::fabric::Channel<eq::server::Window, eq::server::Channel> const&)]+0x61): undefined reference to vtable for eq::fabric::Object' CMakeFiles/lib_EqualizerServer_shared.dir/objects.a(channel.cpp.obj):channel.cpp:(.text$_ZN2eq6fabric7ChannelINS_6server6WindowENS2_7ChannelEEC1ERKS5_[eq::fabric::Channel<eq::server::Window, eq::server::Channel>::Channel(eq::fabric::Channel<eq::server::Window, eq::server::Channel> const&)]+0x61): undefined reference tovtable for eq::fabric::Object'

I tried to link with eq_fabric to solve this, but I don't know how this works with CMake, and somehow I think that this should not be done anyway.

Martin

@marlam
Copy link
Contributor Author

marlam commented May 9, 2011

It seems I cannot attach a patch to an issue, so I paste the patch here and hope the formatting survives this:

diff --git a/externals/UsePthreads.cmake b/externals/UsePthreads.cmake
index d5e7fa5..43a8376 100644
--- a/externals/UsePthreads.cmake
+++ b/externals/UsePthreads.cmake
@@ -52,7 +52,7 @@ add_library(pthread SHARED
)

set_target_properties(pthread PROPERTIES COMPILE_DEFINITIONS PTW32_BUILD=1 FOLDER "Externals")
-target_link_libraries(pthread Ws2_32)
+target_link_libraries(pthread ws2_32)

install(TARGETS pthread
ARCHIVE DESTINATION lib COMPONENT codev
diff --git a/libs/client/cudaContext.cpp b/libs/client/cudaContext.cpp
index d84b620..1cf2f3e 100644
--- a/libs/client/cudaContext.cpp
+++ b/libs/client/cudaContext.cpp
@@ -20,7 +20,7 @@
#include "pipe.h"

#ifdef WIN32_API
-# include "wglpipe.h"
+# include "wglPipe.h"
#endif

#ifdef EQ_USE_CUDA
diff --git a/libs/client/wglEventHandler.cpp b/libs/client/wglEventHandler.cpp
index 2f40bfc..c3c385e 100644
--- a/libs/client/wglEventHandler.cpp
+++ b/libs/client/wglEventHandler.cpp
@@ -16,6 +16,7 @@

  • 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    */

+#define _WIN32_WINNT 0x500 // 2000, for WM_XBUTTONDOWN and others
#include <co/base/os.h> // first get windows.h
#include <pthread.h> // then get pthreads
#include <co/base/perThread.h> // then get perThread to have template code
diff --git a/libs/collage/CMakeLists.txt b/libs/collage/CMakeLists.txt
index bf3833c..c5da3a5 100644
--- a/libs/collage/CMakeLists.txt
+++ b/libs/collage/CMakeLists.txt
@@ -27,7 +27,7 @@ add_subdirectory( base )
set(CO_ADD_LINKLIB)

if(WIN32)

  • list(APPEND CO_ADD_LINKLIB Ws2_32 mswsock)
  • list(APPEND CO_ADD_LINKLIB ws2_32 mswsock)
    endif(WIN32)
    if(MSVC)
    list(APPEND CO_SOURCES pgmConnection.cpp)
    diff --git a/libs/collage/base/buffer.h b/libs/collage/base/buffer.h
    index 14ba783..81db1ed 100644
    --- a/libs/collage/base/buffer.h
    +++ b/libs/collage/base/buffer.h
    @@ -21,6 +21,8 @@
    #include <co/base/debug.h> // EQASSERT macro
    #include <co/base/types.h>

+#include // for malloc
+
namespace co
{
namespace base
diff --git a/libs/collage/base/pluginRegistry.cpp b/libs/collage/base/pluginRegistry.cpp
index 19ffda3..9cf9f33 100644
--- a/libs/collage/base/pluginRegistry.cpp
+++ b/libs/collage/base/pluginRegistry.cpp
@@ -33,6 +33,8 @@
#ifdef _MSC_VER

include <direct.h>

define getcwd _getcwd

+#else
+# include <unistd.h> // for getcwd
#endif

#ifndef MAXPATHLEN
diff --git a/libs/collage/base/rng.h b/libs/collage/base/rng.h
index 11c4d0c..1376329 100644
--- a/libs/collage/base/rng.h
+++ b/libs/collage/base/rng.h
@@ -28,7 +28,7 @@

define NOMINMAX

endif

include <wtypes.h>

-# include <WinCrypt.h>
+# include <wincrypt.h>

pragma comment(lib, "advapi32.lib")

#endif

diff --git a/libs/collage/base/uint128_t.cpp b/libs/collage/base/uint128_t.cpp
index 9f2873e..0da9d44 100644
--- a/libs/collage/base/uint128_t.cpp
+++ b/libs/collage/base/uint128_t.cpp
@@ -18,6 +18,8 @@
#include "uint128_t.h"
#include "debug.h"

+#include // for strtoull
+
namespace co
{
namespace base
diff --git a/libs/collage/connectionDescription.cpp b/libs/collage/connectionDescription.cpp
index f69a86c..b9e182c 100644
--- a/libs/collage/connectionDescription.cpp
+++ b/libs/collage/connectionDescription.cpp
@@ -209,9 +209,9 @@ void ConnectionDescription::setHostname( const std::string& hostname )
_hostname = hostname;
}

-void ConnectionDescription::setInterface( const std::string& interface )
+void ConnectionDescription::setInterface( const std::string& interface_ )
{

  • _interface = interface;
  • interface = interface;
    }

void ConnectionDescription::setFilename( const std::string& filename )

@ghost ghost assigned eile May 11, 2011
@eile
Copy link
Member

eile commented May 11, 2011

To contribute code changes, please do the following:

Fork the repository
Clone the fork to your machine
edit, commit, push

Then we'll see the pending commits on your side and can merge them easily. Optionally send a push request, if we don't pick it up automatically.

@eile
Copy link
Member

eile commented May 11, 2011

Re your issue: can you compile with 'make VERBOSE=1' and add the full link command here?

@marlam
Copy link
Contributor Author

marlam commented May 12, 2011

This is the full link command:

Linking CXX shared library ../../bin/libEqualizerServer.dll
cd /home/lambers/src/equalizer/build-mce/libs/server && /usr/bin/cmake -E cmake_link_script CMakeFiles/lib_EqualizerServer_shared.dir/link.txt --verbose=1
/usr/bin/cmake -E remove -f CMakeFiles/lib_EqualizerServer_shared.dir/objects.a
/var/tmp/mingw-cross-env-2.19/usr/bin/i686-pc-mingw32-ar cr CMakeFiles/lib_EqualizerServer_shared.dir/objects.a @CMakeFiles/lib_EqualizerServer_shared.dir/objects1.rsp
/var/tmp/mingw-cross-env-2.19/usr/bin/i686-pc-mingw32-g++ -L/home/lambers/install/lib -shared -o ../../bin/libEqualizerServer.dll -Wl,--out-implib,libEqualizerServer.dll.a -Wl,--major-image-version,1,--minor-image-version,1 -Wl,--whole-archive CMakeFiles/lib_EqualizerServer_shared.dir/objects.a -Wl,--no-whole-archive ../client/libEqualizer.dll.a ../collage/libCollage.dll.a -lpthread -lws2_32 -lmswsock ../../libglew-1.5.8-MX-Equalizer.a -lglu32 -lopengl32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
Creating library file: libEqualizerServer.dll.a
CMakeFiles/lib_EqualizerServer_shared.dir/objects.a(channel.cpp.obj):channel.cpp:(.text$ZN2eq6fabric7ChannelINS_6server6WindowENS2_7ChannelEEC2ERKS5[eq::fabric::Channel<eq::server::Window, eq::server::Channel>::Channel(eq::fabric::Channel<eq::server::Window, eq::server::Channel> const&)]+0x61): undefined reference to vtable for eq::fabric::Object' CMakeFiles/lib_EqualizerServer_shared.dir/objects.a(channel.cpp.obj):channel.cpp:(.text$_ZN2eq6fabric7ChannelINS_6server6WindowENS2_7ChannelEEC1ERKS5_[eq::fabric::Channel<eq::server::Window, eq::server::Channel>::Channel(eq::fabric::Channel<eq::server::Window, eq::server::Channel> const&)]+0x61): undefined reference tovtable for eq::fabric::Object'
collect2: ld returned 1 exit status

@marlam marlam closed this as completed May 12, 2011
@eile
Copy link
Member

eile commented May 12, 2011

The symbol should be in libEqualizer:

eile% nm debug/libs/client/libEqualizer.dylib |c++filt|grep vtable|grep Object
001c8290 S vtable for eq::util::ObjectManager<void const*>::SharedData
001c82a0 S vtable for eq::util::ObjectManager<void const*>
001c7040 S vtable for eq::Config::LatencyObject
001c4f60 S vtable for eq::fabric::Object

You closed the issue - is it solved?

@marlam
Copy link
Contributor Author

marlam commented May 12, 2011

Sorry for closing this, it was by accident.

You are right, the symbol indeed is in libEqualizer:
lambers@jones:~/src/equalizer/build-mce$ i686-pc-mingw32-nm bin/libEqualizer.dll | /var/tmp/mingw-cross-env-2.19/usr/bin/i686-pc-mingw32-c++filt | grep vtable | grep Object
6be5b7f8 R vtable for eq::util::ObjectManager<void const*>::SharedData
6be5b808 R vtable for eq::util::ObjectManager<void const*>
6be5b9e0 R vtable for eq::Config::LatencyObject
6be5cf20 R vtable for eq::fabric::Object

The problem seems to be that the -Wl,--no-whole-archive option does not work correctly with my version of g++: it does not undo the effects of -Wl,--whole-archive. If I link without -Wl,--whole-archive, it works fine.

So this is not a problem of Equalizer. I'll see if I find a workaround...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants