Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-11-2014, 20:10   #1
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
Linux cross compiling for windows failing

Hi,
I have created a couple of patches under Linux and want to test them out under windows. I have followed the page "http://opencpn.org/ocpn/node/306" and have finally got the compile to work by using the following cmake line rather than the one shown.

cmake -DCMAKE_TOOLCHAIN_FILE=../buildwin/Toolchain-mingw32.cmake -DwxWidgets_CONFIG_EXECUTABLE='/usr/local/i586-mingw32/' -D wxWidgets_CONFIG_EXECUTABLE:FILEPATH=/opt/wxWidgets-2.8.12/wx-config -G "CodeBlocks - Unix Makefiles" ..

I have tried using both wxWidgets-2.8.12 and wxWidgets-3.0.2. I did a make of the wxWidgets but I did not do an install as the "wxWidgets_CONFIG_EXECUTABLE:FILEPATH" seems to fix it up.

However, the link is failing. Here is the output I get:

-- *** Build Architecture is i386
-- *** Staging to build opencpn 3.3.2118 ***
-- *** Package will include documentation ***
-- *** Package will include GSHHS basechart level: CRUDE ***
-- *** Package will include tide and current data ***
-- Found OpenGL...
-- Lib: glu32opengl32
-- Include:
-- Found wxWidgets...
-- -L/opt/wxWidgets-2.8.12/lib;;-mthreads;;-Wl,--subsystem,windows;-mwindows;-lwx_mswu_gl-2.8-i586-mingw32msvc;-lwx_baseu_net-2.8-i586-mingw32msvc;-lwx_baseu_xml-2.8-i586-mingw32msvc;-lwx_mswu_html-2.8-i586-mingw32msvc;-lwx_mswu_adv-2.8-i586-mingw32msvc;-lwx_mswu_aui-2.8-i586-mingw32msvc;-lwx_mswu_core-2.8-i586-mingw32msvc;-lwx_baseu-2.8-i586-mingw32msvc
--
-- *** Staging to build opencpn ***
-- Build type: Release
-- *** Will install to /data/public/working\ area/opencpn/cross/OpenCPN/build-mingw32-cross ***
-- tinyxml library not found
-- S57 ENC support: enabled
-- Garmin Host Mode support: enabled
-- Compiling texture compression library with sse support
--
-- *** Staging to build PlugIns ***
--
-- *** Staging to build dashboard_pi ***
-- *** Staging to build grib_pi ***
-- Writing spec file...
-- Configuring done
-- Generating done
-- Build files have been written to: /data/public/working area/opencpn/cross/OpenCPN/build-mingw32-cross
make[1]: Warning: File `CMakeFiles/Makefile2' has modification time 0.25 s in the future
[ 4%] Built target GARMINHOST
[ 12%] Built target NMEA0183
[ 25%] Built target S57ENC
[ 28%] Built target TEXCMP
[ 30%] i18n: Done.
[ 36%] Built target i18n
[ 63%] Built target opencpn
[ 65%] dashboard_pi-i18n: Done.
[ 71%] Built target dashboard-i18n
[ 86%] Built target dashboard_pi
[ 89%] Built target LIB_BZIP
[ 89%] grib_pi-i18n: Done.
[ 95%] Built target grib-i18n
Linking CXX shared library libgrib_pi.dll
/usr/bin/i686-w64-mingw32-ld: cannot find -lz
collect2: error: ld returned 1 exit status
make[2]: *** [plugins/grib_pi/libgrib_pi.dll] Error 1
make[1]: *** [plugins/grib_pi/CMakeFiles/grib_pi.dir/all] Error 2
make: *** [all] Error 2


The link command is setup in "plugins/grib_pi/CMakeLists.txt" and the offending section is:

IF(WIN32)
IF(MSVC)
SET(OPENCPN_IMPORT_LIB "../../${CMAKE_CFG_INTDIR}/${PARENT}")
ELSE(MSVC)
SET(OPENCPN_IMPORT_LIB "${PARENT}.dll")
SET( CMAKE_SHARED_LINKER_FLAGS "-L../../" )
TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${OPENGL_LIBRARIES} "-lz")
ENDIF(MSVC)

TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} LIB_BZIP ${OPENCPN_IMPORT_LIB})
ADD_DEPENDENCIES(${PACKAGE_NAME} ${PARENT})
ENDIF(WIN32)


Does anyone know how to fix the "-lz" not found message generated by this code? The CMakeLists.txt file is auto generated by the cmake command.

Thanks
Jon
__________________

__________________
jongough is offline   Reply With Quote
Old 02-11-2014, 20:40   #2
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,018
Re: Linux cross compiling for windows failing

Jon...
I haven't tried, but are you sure you have zlib in the mingw environment?
If not, there are some build instructions for example at http://go.kblog.us/2009/06/mingw-compiling-zlib.html
And the core is already built where you are stuck, so if the changes are not in the grib plugin itself, you already have a working opencpn.exe

Pavel
__________________

__________________
nohal is offline   Reply With Quote
Old 02-11-2014, 20:58   #3
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 2,813
Re: Linux cross compiling for windows failing

Yes, unfortunately this is a bit clunky.

You need to build libz manually and install it.

I am now wondering how this works on windows using msvc. Do they rely on buildling libz into wxWidgets? If so, perhaps we should also require this for mingw?
__________________
boat_alexandra is offline   Reply With Quote
Old 02-11-2014, 21:02   #4
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 2,813
Re: Linux cross compiling for windows failing

Quote:
Originally Posted by jongough View Post
Hi,
I have created a couple of patches under Linux and want to test them out under windows. I have followed the page "http://opencpn.org/ocpn/node/306" and have finally got the compile to work by using the following cmake line rather than the one shown.

cmake -DCMAKE_TOOLCHAIN_FILE=../buildwin/Toolchain-mingw32.cmake -DwxWidgets_CONFIG_EXECUTABLE='/usr/local/i586-mingw32/' -D wxWidgets_CONFIG_EXECUTABLE:FILEPATH=/opt/wxWidgets-2.8.12/wx-config -G "CodeBlocks - Unix Makefiles" ..
Did you try adding the wx-config you want to use to the PATH environment variable instead?
Quote:
I have tried using both wxWidgets-2.8.12 and wxWidgets-3.0.2. I did a make of the wxWidgets but I did not do an install as the "wxWidgets_CONFIG_EXECUTABLE:FILEPATH" seems to fix it up.
Yes, well, you don't need to do an install if you add the wxWidgets build directory to PATH.
__________________
boat_alexandra is offline   Reply With Quote
Old 02-11-2014, 21:17   #5
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,018
Re: Linux cross compiling for windows failing

Quote:
Originally Posted by boat_alexandra View Post
Yes, unfortunately this is a bit clunky.

You need to build libz manually and install it.

I am now wondering how this works on windows using msvc. Do they rely on buildling libz into wxWidgets? If so, perhaps we should also require this for mingw?
Sean...
On Windows we use our bundled zlib and bz2lib as far as I can remember.

Pavel
__________________
nohal is offline   Reply With Quote
Old 02-11-2014, 22:15   #6
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 2,813
Re: Linux cross compiling for windows failing

Quote:
Originally Posted by nohal View Post
Sean...
On Windows we use our bundled zlib and bz2lib as far as I can remember.

Pavel
Are they static libraries? bz2lib is build from source into grib currently, but not zlib. Perhaps it could be. Where do the binaries for zlib come from?
__________________
boat_alexandra is offline   Reply With Quote
Old 02-11-2014, 22:30   #7
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
Re: Linux cross compiling for windows failing

I am trying to get it all working at the moment so I am trying not to modify my environment too much. When I get it working I may add it to the path, but I will have to see how much hassle it is.

Quote:
Originally Posted by boat_alexandra View Post
Did you try adding the wx-config you want to use to the PATH environment variable instead?

Yes, well, you don't need to do an install if you add the wxWidgets build directory to PATH.
__________________
jongough is offline   Reply With Quote
Old 02-11-2014, 23:04   #8
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,018
Re: Linux cross compiling for windows failing

Sean...
In native Windows build, the libs from WX are used. From my CMakeCache.txt:
Code:
//Cleared.
WX_zlib:FILEPATH=C:/wxWidgets-2.8.12/lib/vc_dll/wxzlib.lib

//Cleared.
WX_zlibd:FILEPATH=C:/wxWidgets-2.8.12/lib/vc_dll/wxzlibd.lib
Pavel
__________________
nohal is offline   Reply With Quote
Old 02-11-2014, 23:29   #9
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
Re: Linux cross compiling for windows failing

Are there any special instructions for this? Being on Ubuntu I am not sure if it will pickup the mingw stuff automagically?

I have libz downloaded and have done a make/make install but that has not worked.

I tried the following commands to build zlib-1.2.8:

sudo ./configure
Checking for gcc...
Checking for shared library support...
Building shared library libz.so.1.2.8 with gcc.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for strerror... Yes.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for attribute(visibility) support... Yes.


sudo make -f win32/Makefile.gcc CC=/usr/bin/i686-w64-mingw32-gcc RC=/usr/bin/i686-w64-mingw32-windres
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o adler32.o adler32.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o compress.o compress.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o crc32.o crc32.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o deflate.o deflate.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o gzclose.o gzclose.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o gzlib.o gzlib.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o gzread.o gzread.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o gzwrite.o gzwrite.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o infback.o infback.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o inffast.o inffast.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o inflate.o inflate.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o inftrees.o inftrees.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o trees.o trees.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o uncompr.o uncompr.c
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -c -o zutil.o zutil.c
ar rcs libz.a adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
/usr/bin/i686-w64-mingw32-gcc -shared -Wl,--out-implib,libz.dll.a \
-o zlib1.dll win32/zlib.def adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o zlibrc.o
strip zlib1.dll
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -I. -c -o example.o test/example.c
/usr/bin/i686-w64-mingw32-gcc -o example.exe example.o libz.a
strip example.exe
/usr/bin/i686-w64-mingw32-gcc -O3 -Wall -I. -c -o minigzip.o test/minigzip.c
/usr/bin/i686-w64-mingw32-gcc -o minigzip.exe minigzip.o libz.a
strip minigzip.exe
/usr/bin/i686-w64-mingw32-gcc -o example_d.exe example.o libz.dll.a
strip example_d.exe
/usr/bin/i686-w64-mingw32-gcc -o minigzip_d.exe minigzip.o libz.dll.a
strip minigzip_d.exe


followed by "sudo make install", which seemed to complete.
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/adler32.o adler32.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/crc32.o crc32.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/deflate.o deflate.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/infback.o infback.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inffast.o inffast.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inflate.o inflate.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inftrees.o inftrees.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/trees.o trees.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/zutil.o zutil.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/compress.o compress.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/uncompr.o uncompr.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzclose.o gzclose.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzlib.o gzlib.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzread.o gzread.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzwrite.o gzwrite.c
gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o libz.so.1.2.8 adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo -lc
rm -f libz.so libz.so.1
ln -s libz.so.1.2.8 libz.so
ln -s libz.so.1.2.8 libz.so.1
cp libz.a /usr/local/lib
chmod 644 /usr/local/lib/libz.a
cp libz.so.1.2.8 /usr/local/lib
chmod 755 /usr/local/lib/libz.so.1.2.8
cp zlib.3 /usr/local/share/man/man3
chmod 644 /usr/local/share/man/man3/zlib.3
cp zlib.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/zlib.pc
cp zlib.h zconf.h /usr/local/include
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h

however I still get from the make command:

Linking CXX shared library libgrib_pi.dll
/usr/bin/i686-w64-mingw32-ld: cannot find -lz
collect2: error: ld returned 1 exit status


So I am doing something wrong, just not sure what.

Quote:
Originally Posted by boat_alexandra View Post
Yes, unfortunately this is a bit clunky.

You need to build libz manually and install it.

I am now wondering how this works on windows using msvc. Do they rely on buildling libz into wxWidgets? If so, perhaps we should also require this for mingw?
__________________
jongough is offline   Reply With Quote
Old 03-11-2014, 01:42   #10
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 2,813
Re: Linux cross compiling for windows failing

Quote:
Originally Posted by jongough View Post
Are there any special instructions for this? Being on Ubuntu I am not sure if it will pickup the mingw stuff automagically?

I have libz downloaded and have done a make/make install but that has not worked.

I tried the following commands to build zlib-1.2.8:



followed by "sudo make install", which seemed to complete.
Remember to set CC also in make install

Quote:
gzclose.lo gzlib.lo gzread.lo gzwrite.lo -lc
rm -f libz.so libz.so.1
ln -s libz.so.1.2.8 libz.so
ln -s libz.so.1.2.8 libz.so.1
cp libz.a /usr/local/lib
chmod 644 /usr/local/lib/libz.a
cp libz.so.1.2.8 /usr/local/lib
chmod 755 /usr/local/lib/libz.so.1.2.8
cp zlib.3 /usr/local/share/man/man3
chmod 644 /usr/local/share/man/man3/zlib.3
cp zlib.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/zlib.pc
cp zlib.h zconf.h /usr/local/include
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h
[/COLOR]
however I still get from the make command:

Linking CXX shared library libgrib_pi.dll
/usr/bin/i686-w64-mingw32-ld: cannot find -lz
collect2: error: ld returned 1 exit status


So I am doing something wrong, just not sure what.
You must not install the libz into /usr/local/lib, but instead set the prefix, probably /usr/local/i686-w64-mingw32/lib or something similar. I use a static library.

I suggest instead we remove the -lz line in CMakeLists.txt for the grib plugin, and add --with-zlib to the configure lines. I believe this is easiest rather than dealing with manually building libz.
__________________
boat_alexandra is offline   Reply With Quote
Old 03-11-2014, 13:14   #11
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
Re: Linux cross compiling for windows failing

I have changed the install location of the zlib as you suggested.

Being new to the whole process, can you tell me where to make the second change you suggested, i.e. using --with-zlib ? I am not quite sure where to put this.

Quote:
Originally Posted by boat_alexandra View Post
Remember to set CC also in make install



You must not install the libz into /usr/local/lib, but instead set the prefix, probably /usr/local/i686-w64-mingw32/lib or something similar. I use a static library.

I suggest instead we remove the -lz line in CMakeLists.txt for the grib plugin, and add --with-zlib to the configure lines. I believe this is easiest rather than dealing with manually building libz.
__________________
jongough is offline   Reply With Quote
Old 03-11-2014, 18:25   #12
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 2,813
Re: Linux cross compiling for windows failing

Quote:
Originally Posted by jongough View Post
I have changed the install location of the zlib as you suggested.

Being new to the whole process, can you tell me where to make the second change you suggested, i.e. using --with-zlib ? I am not quite sure where to put this.
This is an option to pass to the configure script when cross compiling wxwidgets, along with others like --with-opengl
__________________
boat_alexandra is offline   Reply With Quote
Old 04-11-2014, 16:19   #13
Registered User

Join Date: May 2013
Location: NSW, Australia
Boat: Richter 42
Posts: 883
Re: Linux cross compiling for windows failing

I have done this but get the error:

Linking CXX shared library libgrib_pi.dll
i686-w64-mingw32-g++: error: unrecognized command line option ‘--with-zlib=/usr/local/i686-w64-mingw32/lib’

Doing a clean 'cmake' of OCPN does not fix it. It appears to be coming from the wxWidgets make.

Quote:
Originally Posted by boat_alexandra View Post
This is an option to pass to the configure script when cross compiling wxwidgets, along with others like --with-opengl
__________________
jongough is offline   Reply With Quote
Old 06-11-2014, 06:46   #14
Registered User
 
Wrong's Avatar

Join Date: Jul 2013
Posts: 1,702
Re: Linux cross compiling for windows failing

The link in /etc/alternatives may be broken. The easiest way to resolve is to install 'galternatives' with yum. Run galternatives from the linux desktop. This is a very useful utility to enable different versions of the same library when multiple versions are installed, and when you want to manually add a library installed from source not automatically added by the system.
__________________
Wrong is offline   Reply With Quote
Old 06-11-2014, 08:29   #15
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 2,813
Re: Linux cross compiling for windows failing

Quote:
Originally Posted by jongough View Post
I have done this but get the error:

Linking CXX shared library libgrib_pi.dll
i686-w64-mingw32-g++: error: unrecognized command line option ‘--with-zlib=/usr/local/i686-w64-mingw32/lib’

Doing a clean 'cmake' of OCPN does not fix it. It appears to be coming from the wxWidgets make.
Sorry for the delayed reply. I got food poisoning...

Anyway, I found that libwxzlib-2.8.a is built by default, so --with-libz is set automatically.

Why I cannot get an environment variable with this value I am not sure, but I have updated the mingw branch so that it should just work without issues, but unfortunately only for a specific version of wx (See plugins/grib_pi/CMakeLists.txt)

WX_zlib:FILEPATH is not set in CMakeCache.txt, and adding zlib to wxWidgets_USE_LIBS doesn't seem to work either
__________________

__________________
boat_alexandra is offline   Reply With Quote
Reply

Tags
linux, wind

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling OpenCPN Windows 8.1 Ptizef OpenCPN 4 22-07-2014 14:08
Compiling & Debug in Windows MSVC rgleason OpenCPN 1 04-07-2014 18:42
Compiling OpenCPN in Windows useris OpenCPN 20 29-06-2013 08:45
Compiling OCPN on Scientific Linux 6.4 64bit HotRod OpenCPN 6 23-05-2013 07:51
Display Differences - Like More Info - Using Linux vs Windows? sdowney717 OpenCPN 2 13-01-2012 12:17



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 12:15.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.