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

Already on GitHub? Sign in to your account

Compilation issue on Mingw32: redeclared without dllimport attribute #104

Closed
nddrylliog opened this Issue Dec 13, 2012 · 15 comments

Comments

Projects
None yet
4 participants

Here's the log:

$ ./configure --prefix=/usr/local --with-libzmq=/usr/local
$ make
*snip*
make[2]: Entering directory `/g/Dev/czmq-1.3.1/src'
/bin/sh ../libtool --tag=CC   --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../include  -Werror -Wall -D_REENTRANT -D_THREAD_SAFE   -I/usr/local/include -g -O2 -MT zclock.lo -MD -MP -MF .deps/zclock.Tpo -c -o zclock.lo zclock.c
libtool: compile:  gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../include -Werror -Wall -D_REENTRANT -D_THREAD_SAFE -I/usr/local/include -g -O2 -MT zclock.lo -MD -MP -MF .deps/zclock.Tpo -c zclock.c  -DDLL_EXPORT -DPIC -o .libs/zclock.o
libtool: compile:  gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../include -Werror -Wall -D_REENTRANT -D_THREAD_SAFE -I/usr/local/include -g -O2 -MT zclock.lo -MD -MP -MF .deps/zclock.Tpo -c zclock.c -o zclock.o >/dev/null 2>&1
make[2]: *** [zclock.lo] Error 1

Upon running the same gcc command by hand, I get these error messages:

zclock.c:70:1: error: 'zclock_sleep' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
zclock.c:97:1: error: 'zclock_time' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
zclock.c:117:1: error: 'zclock_log' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
cc1.exe: all warnings being treated as errors

I don't know how harmful that warning is (never really built DLLs on Windows myself), but with -Werror it does cause the build to fail.

As for my setup, here it is:

  • GCC 4.7.2, 32-bit
  • autotools 2.68
  • GNU m4 1.4.14

That's building czmq 1.3.2, fresh out the release cutter :)

Contributor

pijyoi commented Dec 14, 2012

How about if you configure --disable-static?

Update: I have tried
./configure --with-libzmq=/usr/local --disable-static
and the compilation of the dynamic library works but not for czmq_selftest.exe

The problem is that the *_test() functions called by czmq_selftest.c are not exported in the DLL.
I am not sure exporting the *_test() functions is the right thing to do either.

@ghost

ghost commented Nov 16, 2013

Could you please try again with the latest czmq and zmq? Or could
someone tell me the build process for cross compiling with mingw32?

Contributor

pijyoi commented Nov 16, 2013

I use the toolchain from http://mxe.cc and I create a folder $HOME/local_mingw32.

for libzmq:
CPPFLAGS=-DFD_SETSIZE=1024 ./configure --host=i686-pc-mingw32 --with-libsodium=$HOME/local_mingw32 --prefix=$HOME/local_mingw32

for czmq
./configure --host=i686-pc-mingw32 --with-libzmq=$HOME/local_mingw32 --prefix=$HOME/local_mingw32

Sometimes, there are changes in the source code that break compilation with MinGW32.
Mostly they arise from conflating "Windows platform" with "MSVC compiler".

Contributor

ulikoehler commented Nov 16, 2013

I think we need some kind of guide how to get MinGW+(C)ZMQ build working under wine, because the errors seem to occur somewhat frequently and it seems like most people (including me and Travis) are using pretty much Linux-only throughout the development process.

@ghost

ghost commented Nov 16, 2013

I'll test it now thanks @pijyoi

@ulikoehler if no one else wants to write it then I'll be happy to
whenever I'm free (I'm almost always free). Also I have a dual boot
setup with Windows 7 so I'll reboot into that once a week or so just to
make sure nothing is broken.

Owner

hintjens commented Nov 16, 2013

@shancat regular builds on Windows would be awesome...

@ghost

ghost commented Nov 16, 2013

@pijyoi which packages will I need? At the moment I'm running make gcc
but is there anything else I'll need before compiling
libsodium/zmq/czmq?

@hintjens I'll get started ASAP then :)

Owner

hintjens commented Nov 16, 2013

@shancat neat... :)

Contributor

pijyoi commented Nov 16, 2013

No other package is needed. You just need to build the cross compiler.

Contributor

ulikoehler commented Nov 16, 2013

I can see two different approaches here:

  • Cross-Compiling
  • Running the compiler in wine

The first one would obviously be easier but I'm not entirely sure if it doesn't act different if run (pseudo-)natively on Windows/Wine -- In the past I've had some problems cross-compiling ARMv6L packages for the Raspberry Pi. I didn't really try to track it down, but at least in this case, the native-approach did a better job.

Do you have experience with mingw crosscompiling?

@ghost

ghost commented Nov 16, 2013

I have no experience crosscompiling or with Wine but I'm happy to learn.
I think we should, at the very least, incorporate a MinGW build into
the autobuild. I'm sure I've seen other projects do this so it shouldn't
be too hard.

Baby-steps, we'll see how that goes and if something crops up regarding
MinGW we'll see what we can do regarding Wine. Sound like a plan?

Contributor

ulikoehler commented Nov 16, 2013

Absolutely :)

@ghost

ghost commented Nov 16, 2013

@pijyoi finally finished downloading gcc. Did you do anything special
for libsodium?

Contributor

pijyoi commented Nov 16, 2013

Libsodium builds cleanly with no changes. Just set prefix to local_mingw
like the rest. I believe the win32 binary distributed by libsodium is cross
compiled.

FWIW, czmq_selftest.exe runs without errors under wine. Lots of failures
for the zmq tests though. A lot of them are bind failures due to closing
and rebinding to the same port.

Owner

hintjens commented Jan 29, 2014

No progress on this; closing it.

@hintjens hintjens closed this Jan 29, 2014

@sappo sappo referenced this issue in zeromq/libzmq Nov 20, 2014

Closed

Problem: mingw32 build fails #1259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment