weikipeng / javacpp

Automatically exported from code.google.com/p/javacpp
GNU General Public License v2.0
0 stars 0 forks source link

Can't get LegacyLibrary example to compile in Windows #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Linux the LegacyLibrary example worked out of the box, but I'm having a lot 
of trouble in Windows. I've setup a clean build server with all Windows 
updates, the latest versions of MinGW (g++4.8) and windows sdk 7.1 to run these 
tests. I've attached more detailed logs for each issue.

mvn -v output:
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 
11:22:22-0400)
Maven home: C:\Program Files\Java\apache-maven-3.1.1
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_45\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

======= Bug #1 =======
The MinGW paths in the .properties paths are probably outdated. They should 
reference C:/MinGW/<x> instead of C:/MinGW/local/<x>. 

======= Bug #2 =======
Running "java -jar javacpp.jar LegacyLibrary" with cl set to 
"SetEnv.cmd /Release /x64 /win7" results in the following errors.

jniLegacyLibrary.cpp
C:/MinGW/include/stdio.h(26) : warning C4068: unknown pragma
C:/MinGW/include/_mingw.h(33) : warning C4068: unknown pragma
C:/MinGW/include/sdkddkver.h(26) : warning C4068: unknown pragma
C:/MinGW/include/_mingw.h(51) : fatal error C1189: #error :  ERROR: You must 
use a GNU Compiler.

======= Bug #3 =======
After this I've tried MinGW and replaced the default windows-x86_x64.properties 
with the windows-x86_x64-mingw.properties (and fixed the MinGW paths). 

Btw. is there a better way of switching between properties files ? I haven't 
found anything obvious yet.

This results in the following errors:

jniLegacyLibrary.cpp:1:0: warning: -fPIC ignored for target (all code is 
position independent) [enabled by default]
 /* DO NOT EDIT THIS FILE - IT IS MACHINE GENERATED */
 ^
jniLegacyLibrary.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in

======= Bug #4 =======
Removing -fPic and -amd64 successfully compiles the jniLegacyLibrary.dll. 
However, now I get an unsatisfied linker error due to the missing amd64 mode. 

"Can't load IA 32-bit .dll on a AMD 64-bit platform"

A quick search found that I should install mingw-64 as well, but I haven't had 
time to test that yet.

======================

My experience compiling in Windows is pretty limited, so please stop me if I'm 
going down a wrong path or I'm missing something obvious. I really like the 
idea of your framework and would love to get it to work.

thanks,
Florian

Original issue reported on code.google.com by Florian....@gmail.com on 16 Dec 2013 at 6:28

Attachments:

GoogleCodeExporter commented 9 years ago
I've just tried it with Windows SDK 7.1, and it works just fine. The 
C:/MinGW/local/include is only there as a placeholder for additional header 
files missing from MSVC like msinttypes. C:/MinGW/include/ will cause conflicts 
obviously.

As for MinGW, the original project is quite outdated. MinGW-w64 should be used 
for both x86 and x64 binaries: http://mingw-w64.sourceforge.net/

And we can compile with that on Windows x64 by using the "-properties 
windows-x86_64-mingw" command line option.

Let me know if you have problems with that...

Original comment by samuel.a...@gmail.com on 17 Dec 2013 at 1:04

GoogleCodeExporter commented 9 years ago
You are awesome!

That got both Windows SDK and Mingw64 working. Using C:/MinGW/include seemed 
odd, but I didn't know what the local folder was supposed to link to.

Original comment by Florian....@gmail.com on 17 Dec 2013 at 7:04

GoogleCodeExporter commented 9 years ago
I basically needed the Windows equivalent of the mostly standard /usr/local/ 
directory. C:/MinGW/local/ seemed like the best candidate, but if you know 
something more appropriate, let me know! thanks

Original comment by samuel.a...@gmail.com on 18 Dec 2013 at 1:23

GoogleCodeExporter commented 9 years ago
I've added a link to MinGW-w64:
    http://code.google.com/p/javacpp/
That should remove the confusion for that. Other than that, we obviously need 
more documentation. Let me know if this is something you'd like to work on! 
Thanks

Original comment by samuel.a...@gmail.com on 8 Jan 2014 at 1:19

GoogleCodeExporter commented 9 years ago
I'm no expert on mingw, but I can add some documentation for a basic setup.

Original comment by Florian....@gmail.com on 10 Jan 2014 at 4:14

GoogleCodeExporter commented 9 years ago
I meant for the properties, but maybe it's just something I'll have to do on my 
own at some point.

In any case, sure, anything you feel might help others would be welcome! I've 
given you permission to modify the Wiki, so please feel free to add new pages 
there, thanks!

Original comment by samuel.a...@gmail.com on 10 Jan 2014 at 4:20

GoogleCodeExporter commented 9 years ago
I had forgotten about this issue, but I've fixed that in version 0.9. I've 
removed all those arbitrary paths from the properties. Thanks for reporting!

Original comment by samuel.a...@gmail.com on 26 Aug 2014 at 1:27