jpype-project / jpype

JPype is cross language bridge to allow Python programs full access to Java class libraries.
http://www.jpype.org
Apache License 2.0
1.1k stars 180 forks source link

cc: No valid input files specified, no output generated #927

Closed krowvin closed 2 years ago

krowvin commented 3 years ago

I hope this is the correct place to post Jpype compile issues like this, if not I am all ears and will move this ASAP.

Bit of Background

I sent a pull request a few days ago in regards to having sunos in the platform.py file.

Now that I have cc installed, I am able to use that update. I put print statements in those lines to see that they were working that's the "SUN OS Detected" output.

Issue/Error

I am running into an issue with the _jpype module compiling, giving the following error:

cc: No valid input files specified, no output generated
error: command 'cc' failed with exit status 1

What I have done

I did some research, and was only able to find this post. Unfortunately, I was unable to tell if my issue was similar.

I tried creating my own Makefile with: python setup.py build_ext --makefile and even after changing the line endings to LR, instead of CRLR. I was still unable to compile. I stopped, for fear I was getting into the weeds.

System Info

uname -a returns: SunOS krowvin 5.11 11.4.5.3.0 sun4v sparc sun4v

My version of cc that I am using is: Developer Studio 12.6

You can see at the end I tried manually running the command with CC (the C++ compiler for Solaris.

Terminal Output

  1. Tried importing jpype to see what state it was in, sure enough no _jpype pyc file exists
  2. Cleaned the build from my previously failed attempts
  3. Attempted the Install
  4. Manually tried to run using CC instead of cc
    
    **(jpype) krowvin:~/jpype-master$**  python -c "import jpype; jpype.startJVM(jpype.get_default_jvm_path());import jpypex"
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/krowvin/jpype-master/jpype/__init__.py", line 18, in <module>
    import _jpype
    ModuleNotFoundError: No module named '_jpype'
    **(jpype) krowvin:~/jpype-master$ python setup.py clean --all**
    Falling back to provided JNI headers, since your provided JAVA_HOME "/mysoftware/java/java8/jdk1.8.0_202" does not provide jni.h
    Falling back to provided JNI headers, since your provided JAVA_HOME "/mysoftware/java/java8/jdk1.8.0_202" does not provide jni.h
    Falling back to provided JNI headers, since your provided JAVA_HOME "/mysoftware/java/java8/jdk1.8.0_202" does not provide jni.h
    Found native jni.h at /mysoftware/java/java8/jdk1.8.0_202/include
    SUN OS Detected
    /krowvin/jpype/lib/python3.6/site-packages/setuptools/dist.py:331: UserWarning: Normalizing '1.2.2_dev0' to '1.2.2.dev0'
    normalized_version,
    running clean
    removing 'build/temp.solaris-2.11-sun4v.64bit-3.6' (and everything under it)
    removing 'build/lib.solaris-2.11-sun4v.64bit-3.6' (and everything under it)
    'build/bdist.solaris-2.11-sun4v.64bit' does not exist -- can't clean it
    'build/scripts-3.6' does not exist -- can't clean it
    **(jpype) krowvin:~/jpype-master$ python3 setup.py install**
    Falling back to provided JNI headers, since your provided JAVA_HOME "/mysoftware/java/java8/jdk1.8.0_202" does not provide jni.h
    Falling back to provided JNI headers, since your provided JAVA_HOME "/mysoftware/java/java8/jdk1.8.0_202" does not provide jni.h
    Falling back to provided JNI headers, since your provided JAVA_HOME "/mysoftware/java/java8/jdk1.8.0_202" does not provide jni.h
    Found native jni.h at /mysoftware/java/java8/jdk1.8.0_202/include
    SUN OS Detected
    /krowvin/jpype/lib/python3.6/site-packages/setuptools/dist.py:331: UserWarning: Normalizing '1.2.2_dev0' to '1.2.2.dev0'
    normalized_version,
    running install
    running bdist_egg
    running egg_info
    writing JPype1.egg-info/PKG-INFO
    writing dependency_links to JPype1.egg-info/dependency_links.txt
    writing entry points to JPype1.egg-info/entry_points.txt
    writing requirements to JPype1.egg-info/requires.txt
    writing top-level names to JPype1.egg-info/top_level.txt
    package init file 'jpype/_pyinstaller/__init__.py' not found (or not a regular file)
    reading manifest file 'JPype1.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.jar' under directory 'native'
    warning: no files found matching '*.class' under directory 'native'
    writing manifest file 'JPype1.egg-info/SOURCES.txt'
    installing library code to build/bdist.solaris-2.11-sun4v.64bit/egg
    running install_lib
    running build_py
    creating build/lib.solaris-2.11-sun4v.64bit-3.6
    creating build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_core.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jthread.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/types.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_gui.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jpackage.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jcustomizer.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jio.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/protocol.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jarray.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_classpath.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_pykeywords.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jexception.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/__init__.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jcollection.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/dbapi2.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/beans.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jvmfinder.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jstring.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jclass.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jproxy.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jmethod.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jobject.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/nio.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/imports.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/pickle.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jinit.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    creating build/lib.solaris-2.11-sun4v.64bit-3.6/jpype/_pyinstaller
    copying jpype/_pyinstaller/test_jpype_pyinstaller.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype/_pyinstaller
    copying jpype/_pyinstaller/hook-jpype.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype/_pyinstaller
    copying jpype/_pyinstaller/entry_points.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype/_pyinstaller
    copying jpype/_pyinstaller/example.py -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype/_pyinstaller
    copying jpype/_core.pyi -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jthread.pyi -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jio.pyi -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jstring.pyi -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    copying jpype/_jcollection.pyi -> build/lib.solaris-2.11-sun4v.64bit-3.6/jpype
    running build_ext
    Call build extensions
    Jar cache is missing, using --enable-build-jar to recreate it.
    /mysoftware/java/java8/jdk1.8.0_202/bin/javac -cp lib/asm-8.0.1.jar -d build/temp.solaris-2.11-sun4v.64bit-3.6/org.jpype/classes -g:none -source 1.8 -target 1.8 -encoding UTF-8 native/java/org/jpype/JPypeUtilities.java native/java/org/jpype/JPypeKeywords.java native/java/org/jpype/JPypeSignal.java native/java/org/jpype/JPypeContext.java native/java/org/jpype/PyExceptionProxy.java native/java/org/jpype/html/AttrGrammar.java native/java/org/jpype/html/AttrParser.java native/java/org/jpype/html/HtmlWriter.java native/java/org/jpype/html/Parser.java native/java/org/jpype/html/HtmlGrammar.java native/java/org/jpype/html/HtmlParser.java native/java/org/jpype/html/HtmlHandler.java native/java/org/jpype/html/HtmlTreeHandler.java native/java/org/jpype/html/Html.java native/java/org/jpype/pkg/JPypePackage.java native/java/org/jpype/pkg/JPypePackageManager.java native/java/org/jpype/proxy/JPypeProxy.java native/java/org/jpype/pickle/Encoder.java native/java/org/jpype/pickle/Decoder.java native/java/org/jpype/pickle/ByteBufferInputStream.java native/java/org/jpype/classloader/JPypeClassLoader.java native/java/org/jpype/classloader/DynamicClassLoader.java native/java/org/jpype/javadoc/JavadocExtractor.java native/java/org/jpype/javadoc/JavadocException.java native/java/org/jpype/javadoc/JavadocRenderer.java native/java/org/jpype/javadoc/DomUtilities.java native/java/org/jpype/javadoc/Javadoc.java native/java/org/jpype/javadoc/JavadocTransformer.java native/java/org/jpype/ref/JPypeReference.java native/java/org/jpype/ref/JPypeReferenceSet.java native/java/org/jpype/ref/JPypeReferenceQueue.java native/java/org/jpype/ref/JPypeReferenceNative.java native/java/org/jpype/manager/MethodResolution.java native/java/org/jpype/manager/TypeFactoryNative.java native/java/org/jpype/manager/TypeFactory.java native/java/org/jpype/manager/ModifierCode.java native/java/org/jpype/manager/TypeManager.java native/java/org/jpype/manager/ClassDescriptor.java native/java/org/jpype/manager/TypeAudit.java
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    Copy file native/java/org/jpype/html/entities.txt build/temp.solaris-2.11-sun4v.64bit-3.6/org.jpype/classes/org/jpype/html/entities.txt
    /mysoftware/java/java8/jdk1.8.0_202/bin/jar cvf build/lib.solaris-2.11-sun4v.64bit-3.6/org.jpype.jar -C build/temp.solaris-2.11-sun4v.64bit-3.6/org.jpype/classes .
    added manifest
    adding: org/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/pickle/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/pickle/ByteBufferInputStream.class(in = 1179) (out= 649)(deflated 44%)
    adding: org/jpype/pickle/Decoder.class(in = 683) (out= 406)(deflated 40%)
    adding: org/jpype/pickle/Encoder.class(in = 710) (out= 421)(deflated 40%)
    adding: org/jpype/classloader/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/classloader/DynamicClassLoader$1.class(in = 1876) (out= 790)(deflated 57%)
    adding: org/jpype/classloader/JPypeClassLoader.class(in = 2649) (out= 1413)(deflated 46%)
    adding: org/jpype/classloader/DynamicClassLoader.class(in = 6303) (out= 3073)(deflated 51%)
    adding: org/jpype/JPypeContext.class(in = 9634) (out= 4679)(deflated 51%)
    adding: org/jpype/PyExceptionProxy.class(in = 223) (out= 189)(deflated 15%)
    adding: org/jpype/pkg/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/pkg/JPypePackage.class(in = 4038) (out= 2090)(deflated 48%)
    adding: org/jpype/pkg/JPypePackageManager.class(in = 7815) (out= 3609)(deflated 53%)
    adding: org/jpype/pkg/JPypePackageManager$ModuleDirectory.class(in = 1752) (out= 877)(deflated 49%)
    adding: org/jpype/JPypeUtilities.class(in = 779) (out= 444)(deflated 43%)
    adding: org/jpype/JPypeSignal$1.class(in = 576) (out= 360)(deflated 37%)
    adding: org/jpype/JPypeContext$1.class(in = 480) (out= 311)(deflated 35%)
    adding: org/jpype/manager/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/manager/ClassDescriptor.class(in = 1130) (out= 672)(deflated 40%)
    adding: org/jpype/manager/TypeAudit.class(in = 251) (out= 172)(deflated 31%)
    adding: org/jpype/manager/TypeFactory.class(in = 644) (out= 332)(deflated 48%)
    adding: org/jpype/manager/TypeManager.class(in = 14911) (out= 7068)(deflated 52%)
    adding: org/jpype/manager/ModifierCode.class(in = 2632) (out= 1425)(deflated 45%)
    adding: org/jpype/manager/TypeManager$1.class(in = 177) (out= 135)(deflated 23%)
    adding: org/jpype/manager/MethodResolution.class(in = 4502) (out= 2186)(deflated 51%)
    adding: org/jpype/manager/TypeManager$Destroyer.class(in = 1116) (out= 626)(deflated 43%)
    adding: org/jpype/manager/TypeFactoryNative.class(in = 772) (out= 414)(deflated 46%)
    adding: org/jpype/JPypeKeywords.class(in = 1448) (out= 775)(deflated 46%)
    adding: org/jpype/proxy/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/proxy/JPypeProxy.class(in = 2535) (out= 1254)(deflated 50%)
    adding: org/jpype/javadoc/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/javadoc/DomUtilities.class(in = 3165) (out= 1450)(deflated 54%)
    adding: org/jpype/javadoc/JavadocTransformer.class(in = 9712) (out= 4497)(deflated 53%)
    adding: org/jpype/javadoc/JavadocRenderer.class(in = 7226) (out= 3569)(deflated 50%)
    adding: org/jpype/javadoc/JavadocException.class(in = 277) (out= 198)(deflated 28%)
    adding: org/jpype/javadoc/JavadocTransformer$Workspace.class(in = 916) (out= 430)(deflated 53%)
    adding: org/jpype/javadoc/Javadoc.class(in = 626) (out= 346)(deflated 44%)
    adding: org/jpype/javadoc/JavadocExtractor.class(in = 6370) (out= 3034)(deflated 52%)
    adding: org/jpype/JPypeSignal.class(in = 1711) (out= 820)(deflated 52%)
    adding: org/jpype/ref/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/ref/JPypeReferenceSet$Pool.class(in = 690) (out= 405)(deflated 41%)
    adding: org/jpype/ref/JPypeReferenceNative.class(in = 267) (out= 204)(deflated 23%)
    adding: org/jpype/ref/JPypeReference.class(in = 541) (out= 355)(deflated 34%)
    adding: org/jpype/ref/JPypeReferenceSet.class(in = 1628) (out= 927)(deflated 43%)
    adding: org/jpype/ref/JPypeReferenceQueue.class(in = 3058) (out= 1433)(deflated 53%)
    adding: org/jpype/ref/JPypeReferenceQueue$1.class(in = 185) (out= 143)(deflated 22%)
    adding: org/jpype/ref/JPypeReferenceQueue$Worker.class(in = 1560) (out= 748)(deflated 52%)
    adding: org/jpype/html/(in = 0) (out= 0)(stored 0%)
    adding: org/jpype/html/Parser.class(in = 3984) (out= 1900)(deflated 52%)
    adding: org/jpype/html/HtmlHandler.class(in = 352) (out= 218)(deflated 38%)
    adding: org/jpype/html/Parser$MatchRule.class(in = 1073) (out= 605)(deflated 43%)
    adding: org/jpype/html/HtmlGrammar$Escaped.class(in = 1048) (out= 556)(deflated 46%)
    adding: org/jpype/html/AttrGrammar$EndQuoteRule.class(in = 1130) (out= 564)(deflated 50%)
    adding: org/jpype/html/HtmlGrammar$Directive.class(in = 910) (out= 476)(deflated 47%)
    adding: org/jpype/html/Parser$1.class(in = 161) (out= 132)(deflated 18%)
    adding: org/jpype/html/HtmlParser.class(in = 531) (out= 306)(deflated 42%)
    adding: org/jpype/html/AttrGrammar.class(in = 2221) (out= 984)(deflated 55%)
    adding: org/jpype/html/HtmlGrammar$Token.class(in = 2243) (out= 1174)(deflated 47%)
    adding: org/jpype/html/AttrGrammar$State.class(in = 1830) (out= 776)(deflated 57%)
    adding: org/jpype/html/AttrGrammar$BooleanRule.class(in = 1209) (out= 634)(deflated 47%)
    adding: org/jpype/html/Parser$Entity.class(in = 774) (out= 391)(deflated 49%)
    adding: org/jpype/html/HtmlGrammar$StartComment.class(in = 1554) (out= 723)(deflated 53%)
    adding: org/jpype/html/HtmlGrammar$1.class(in = 171) (out= 136)(deflated 20%)
    adding: org/jpype/html/AttrGrammar$IgnoreWSRule.class(in = 819) (out= 458)(deflated 44%)
    adding: org/jpype/html/HtmlGrammar$CompleteElement.class(in = 1709) (out= 853)(deflated 50%)
    adding: org/jpype/html/HtmlGrammar$BeginElement.class(in = 2130) (out= 962)(deflated 54%)
    adding: org/jpype/html/HtmlGrammar$EndElement.class(in = 1392) (out= 664)(deflated 52%)
    adding: org/jpype/html/Parser$Grammar.class(in = 254) (out= 165)(deflated 35%)
    adding: org/jpype/html/AttrGrammar$QuoteRule.class(in = 1087) (out= 545)(deflated 49%)
    adding: org/jpype/html/HtmlGrammar.class(in = 5251) (out= 2249)(deflated 57%)
    adding: org/jpype/html/Parser$State.class(in = 349) (out= 198)(deflated 43%)
    adding: org/jpype/html/HtmlGrammar$Cleanup.class(in = 2482) (out= 1179)(deflated 52%)
    adding: org/jpype/html/Parser$Token.class(in = 215) (out= 167)(deflated 22%)
    adding: org/jpype/html/HtmlGrammar$Comment.class(in = 1744) (out= 805)(deflated 53%)
    adding: org/jpype/html/HtmlGrammar$EndCData.class(in = 1648) (out= 834)(deflated 49%)
    adding: org/jpype/html/HtmlGrammar$StartQuote.class(in = 1259) (out= 611)(deflated 51%)
    adding: org/jpype/html/HtmlGrammar$CData.class(in = 1700) (out= 777)(deflated 54%)
    adding: org/jpype/html/AttrParser.class(in = 649) (out= 360)(deflated 44%)
    adding: org/jpype/html/AttrGrammar$AttrRule.class(in = 1223) (out= 641)(deflated 47%)
    adding: org/jpype/html/HtmlWriter.class(in = 3444) (out= 1779)(deflated 48%)
    adding: org/jpype/html/entities.txt(in = 3616) (out= 1559)(deflated 56%)
    adding: org/jpype/html/HtmlGrammar$Quoted.class(in = 1638) (out= 748)(deflated 54%)
    adding: org/jpype/html/HtmlTreeHandler.class(in = 5222) (out= 2595)(deflated 50%)
    adding: org/jpype/html/HtmlGrammar$StartElement.class(in = 1624) (out= 784)(deflated 51%)
    adding: org/jpype/html/HtmlGrammar$State.class(in = 2080) (out= 905)(deflated 56%)
    adding: org/jpype/html/AttrGrammar$Token.class(in = 1791) (out= 931)(deflated 48%)
    adding: org/jpype/html/Parser$Rule.class(in = 351) (out= 197)(deflated 43%)
    adding: org/jpype/html/HtmlGrammar$EndDirective.class(in = 1404) (out= 677)(deflated 51%)
    adding: org/jpype/html/HtmlGrammar$MergeText.class(in = 996) (out= 525)(deflated 47%)
    adding: org/jpype/html/Html.class(in = 5891) (out= 3223)(deflated 45%)
    adding: org/jpype/html/HtmlGrammar$EndComment.class(in = 1670) (out= 853)(deflated 48%)
    Call build ext
    building '_jpype' extension
    creating build/temp.solaris-2.11-sun4v.64bit-3.6/native
    creating build/temp.solaris-2.11-sun4v.64bit-3.6/native/common
    creating build/temp.solaris-2.11-sun4v.64bit-3.6/native/python
    cc -DNDEBUG -O -m64 -std=c99 -m64 -std=c99 -xcode=pic32 -Inative/common/include -Inative/python/include -Inative/embedded/include -I/mysoftware/java/java8/jdk1.8.0_202/include -I/mysoftware/java/java8/jdk1.8.0_202/include/solaris -I/krowvin/jpype/include -I/mysoftware/python/v3.6.4/include/python3.6m -c native/common/jp_arrayclass.cpp -o build/temp.solaris-2.11-sun4v.64bit-3.6/native/common/jp_arrayclass.o
    cc: No valid input files specified, no output generated
    error: command 'cc' failed with exit status 1
    **(jpype) krowvin:~/jpype-master$** CC -DNDEBUG -O -m64 -std=c99 -m64 -std=c99 -xcode=pic32 -Inative/common/include -Inative/python/include -Inative/embedded/include -I/mysoftware/java/java8/jdk1.8.0_202/include -I/mysoftware/java/java8/jdk1.8.0_202/include/solaris -I/krowvin/jpype/include -I/mysoftware/python/v3.6.4/include/python3.6m -c native/common/jp_arrayclass.cpp -o build/temp.solaris-2.11-sun4v.64bit-3.6/native/common/jp_arrayclass.o
    CC: illegal option usage -std=c99
    CC: illegal option usage -std=c99
    (jpype) krowvin:~/jpype-master$
Thrameos commented 3 years ago

This is certainly the correct place. The first thing that we need to address is what is the official compiler for Python on sun? I assume it is CC but it has been years since I used a sun system. There is a requirement that all Python modules use the same compiler (or variant of in the case of C++). If our platform is gcc then using the vendor compiler would be a bad start. There are ways to get this both from command line and also from internal Python module variables.

https://stackoverflow.com/questions/15350780/how-to-check-which-compiler-was-used-to-build-python

The makefile that we build with --makefile uses the options in platform.py. The defaults are for g++ so it is not unexpected that some (or all) or the command line arguments may be off. Trim off any arguments in the makefile that do not apply. Then you will need to deal with compiler failures on things like "nothrow" depending on what the standard of C++ that sun is supplying. Once you have a working makefile save it and then port the required options to platform.py.

krowvin commented 3 years ago

Hello again Thrameos,

Checking the compiler for python from the link you provided returns:

python3 -c "import sys; print(sys.version)"
3.6.4 (default, Apr 9 2018, 14:45:48) [C] 

Calling the interpreter returns

python3
Python 3.6.4 (default, Apr 9 2018, 14:45:48) [C] on sunos5

Seeing it's just C, would that be cc? Which I believe is the c compiler for Solaris.

Some more details about my attempt at compiling with CC:

For starters,

I tried removing -std=c99 from the command, and I also set every include to the full path. My thought process was that the include file was cpp, while "cc" is a the C compiler (not CPP).

This was the output/command i'm currently working with:

Should I go back to cc? The errors make me think it's compatibility issues going from dos to unix.

Side note, I did try fixing a few by the time I did this run. Adding a new line does make these go away.

Not sure about the "," expected error

(jpype) krowvin:~/jpype-master$ CC -DNDEBUG -O -m64 -xcode=pic32 -I/krowvin/jpype-master/native/common/include -I/krowvin/jpype-master/native/python/include -I/krowvin/jpype-master/native/embedded/include -I/mysoftware/java/java8/jdk1.8.0202/include -I/mysoftware/java/java8/jdk1.8.0202/include/solaris -I/krowvin/jpype/include -I/mysoftware/python/v3.6.4/include/python3.6m -c /krowvin/jpype-master/native/common/jparrayclass.cpp -o /krowvin/jpype-master/build/temp.solaris-2.11-sun4v.64bit-3.6/native/common/jparrayclass.o

"/krowvin/jpype-master/native/common/include/jpype.h", line 193: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jp_tracer.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jpype.h", line 195: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jp_typemanager.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jpype.h", line 196: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jp_encoding.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jp_encoding.h", line 43: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_encoding.h", line 46: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_encoding.h", line 53: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_encoding.h", line 58: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jpype.h", line 197: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jp_modifier.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jpype.h", line 198: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jp_match.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jpype.h", line 201: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jp_classhints.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jp_classhints.h", line 35: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_classhints.h", line 43: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_classhints.h", line 50: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_classhints.h", line 51: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_classhints.h", line 52: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jpype.h", line 202: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jp_method.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jpvalue.h", line 19: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jpclass.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jpype.h", line 207: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jp_primitivetype.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jpprimitivetype.h", line 18: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jpboxedtype.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jp_boxedtype.h", line 41: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_boxedtype.h", line 42: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_boxedtype.h", line 50: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_primitivetype.h", line 27: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_arrayclass.h", line 33: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_arrayclass.h", line 34: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_arrayclass.h", line 35: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_arrayclass.h", line 57: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/jparrayclass.cpp", line 20: Warning: Last line in file "/krowvin/jpype-master/native/common/include/jpstringtype.h" is not terminated with a newline.

"/krowvin/jpype-master/native/common/include/jp_stringtype.h", line 32: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_stringtype.h", line 33: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_stringtype.h", line 34: Error: "," expected instead of "override".

"/krowvin/jpype-master/native/common/include/jp_stringtype.h", line 35: Error: "," expected instead of "override".

21 Error(s) and 11 Warning(s) detected.

One additional detail, since you mentioned the systems python this might be relevant.

The system has Python 3.5.2 installed by default for python3. I have exported a new path that points to a python 3.6.4 directory, overriding the python3.5 path in .bashrc.

I also have a python 3.8.0 directory, and debated trying the compile with that in the path instead.

Thrameos commented 3 years ago

Compiler

C is pretty unhelpful. But as it isn't gcc I would guess you are correct that it must have been CC.

Warnings

The warnings are just about unterminated lines. This isn't a dos or unix issue. It is simply that the files were formatted without a newline at the end which appears to be a warning for this compiler. I believe those are safe to ignore.

Errors

The errors indicate that CC does not recognize the C++ keyword "override"

https://en.cppreference.com/w/cpp/language/override

override was introduced in C++-11. So the C++ compiler that you are attempting to use is likely very old or has an older standard as the default. The override specification optional so we have a few ways to get around it. Unfortunately if you are not C++-11 compliant then you are likely to run into a whole lot of additional issues. There are also going to be issues with nothrow or similar specifications as JPype is written for C++11 or later.

Looking over the docs for Developer Studio 12.4 it seems like adding --std=c++11 to the arguments should fix it.

https://docs.oracle.com/cd/E37069_01/html/E37071/gndfg.html

Of course having once been a sysadmin for sun and HPUX machines I know that frequently vendors are misleading about the level of compliance. If that is the case then you would have to try adding #define override at the top of the jpype.h header to remove the optional specification.

Advice

Unfortunately you are diving into deep water. Porting to a new compiler is usually non-trivial. The expected errors will be one of

I am not saying "Abandon all hope all ye who enter here" but there is a non-trivial possibility that you could start the porting work and get to point that is very challenging to proceed. Depending on your level of technical comfort it may not be worth your effort. As a programmer with 25 years of experience I have been outside by comfort zone at times and taken weeks to find nasty compatibility bugs. That said I will try my best to advise you on these issues as porting to other platforms is always appreciated. I just can't guarantee success.

krowvin commented 3 years ago

I have been outside by comfort zone at times

I'm struggling, but I like to think I/we have gotten somewhere. I'm not quite 25 years of experience, but I am grateful for all your help.

From what you mentioned

I tried adding --std=c++11, but it still failed (Showed the same override errors) i.e. "native/common/include/jp_encoding.h", line 58: Error: "," expected instead of " override".

Re/defining the override in the jype header file allowed the command to run with zero errors (Just the warnings we discussed). But it did not continue with the rest of the compile, as I was manually running the command with CC instead of part of the setup.py (For debugging).

Trying to force setup.py to use CC/GCC

I tried using export cc=CC, but it still tried to compile with cc. Is there a way to change the default compiler, or does python decide that? Once I have gcc installed, I would rather go with it - seeing as Solaris compile tools are a bit... Mystical (To me at least).

Here is the output of CC working manually in the terminal:

(jpype) krowvin:~/jpype-master$ CC -DNDEBUG -O -m64 --std=c++11 -xcode=pic32 -Inative/common/include -Inative/python/include -Inative/embedded/include -I/mysoftware/java/java8/jdk1.8.0_202/include -I/mysoftware/java/java8/jdk1.8.0_202/include/solaris -I/home/usace/m5ec9crg/jpype/include -I/mysoftware/python/v3.6.4/include/python3.6m -c native/common/jp_arrayclass.cpp -o build/temp.solaris-2.11-sun4v.64bit-3.6/native/common/jp_arrayclass.o
CC: Warning: Option --std=c++11 passed to ld, if ld is invoked, ignored otherwise
"native/common/include/jpype.h", line 195: Warning: Last line in file "native/common/include/jp_tracer.h" is not terminated with a newline.
"native/common/include/jpype.h", line 197: Warning: Last line in file "native/common/include/jp_typemanager.h" is not terminated with a newline.
"native/common/include/jpype.h", line 198: Warning: Last line in file "native/common/include/jp_encoding.h" is not terminated with a newline.
"native/common/include/jpype.h", line 199: Warning: Last line in file "native/common/include/jp_modifier.h" is not terminated with a newline.
"native/common/include/jpype.h", line 200: Warning: Last line in file "native/common/include/jp_match.h" is not terminated with a newline.
"native/common/include/jpype.h", line 203: Warning: Last line in file "native/common/include/jp_classhints.h" is not terminated with a newline.
"native/common/include/jpype.h", line 204: Warning: Last line in file "native/common/include/jp_method.h" is not terminated with a newline.
"native/common/include/jp_value.h", line 19: Warning: Last line in file "native/common/include/jp_class.h" is not terminated with a newline.
"native/common/include/jpype.h", line 209: Warning: Last line in file "native/common/include/jp_primitivetype.h" is not terminated with a newline.
"native/common/include/jp_primitivetype.h", line 18: Warning: Last line in file "native/common/include/jp_boxedtype.h" is not terminated with a newline.
"native/common/jp_arrayclass.cpp", line 20: Warning: Last line in file "native/common/include/jp_stringtype.h" is not terminated with a newline.
11 Warning(s) detected.

I am looking into getting gcc installed on the system.

It looks like Developer Studio 12.6 (What is installed on the system) is the latest Oracle has to offer.

Would I need to do something in particular with python3 in order to make the compilation work against gcc instead of cc/CC?

Thrameos commented 3 years ago

Manual build

If you can get it to compile without errors, then just edit the makefile, call make, and it will build the module. Typically you will find the resulting module under build/lib.${arch} . Just copy it and the org.jpype.jar to the top level and run python -m pytest test/jpypetest and see if it worked. If it does then you can use python setup.py install to complete the process. I rarely run the setup.py version as I am doing development. It is just a matter of getting things in the right place after the build completes.

Getting setup.py to use settings

The compiler is typically controlled by the setuptools/distutils that come with Python. They have a lot of options and such, but the documentation is often so bad that I end up having to go read the source code until I figure out how they intended for it to work. Your guess on setting cc=CC seems very reasonable but you have to get into build_ext in distutils (and the patches that get added in setuptools) to see what env variable it pulls. It is a real pain because you have to read through the layering caused by the distutils, distutils/ccompiler, distutils/unixcompiler.py, setuptools/*, and then the project copy (setupext/build_ext). But if you got it to a makefile and got it working once I can likely guide you how to alter platform.py to make that the default for the system.

https://docs.python.org/3/extending/building.html

My guess is the the export cc is only used for C compilation and that Python looks at a different variable for C++ compilation. As this is challenging I will show you how I go about it... Starting from distutils lets grep for "cc" which takes us to this section.

From unixcompiler.py


    # These are used by CCompiler in two places: the constructor sets
    # instance attributes 'preprocessor', 'compiler', etc. from them, and
    # 'set_executable()' allows any of these to be set.  The defaults here
    # are pretty generic; they will probably have to be set by an outsider
    # (eg. using information discovered by the sysconfig about building
    # Python extensions).
    executables = {'preprocessor' : None,
                   'compiler'     : ["cc"],
                   'compiler_so'  : ["cc"],
                   'compiler_cxx' : ["cc"],
                   'linker_so'    : ["cc", "-shared"],
                   'linker_exe'   : ["cc"],
                   'archiver'     : ["ar", "-cr"],
                   'ranlib'       : None,
                  }

    if sys.platform[:6] == "darwin":

So now we know that there is a map which has the default "compiler_cxx" so lets grep again to see where it interacts with environ calls. This leads us to sysconfig.py

(cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags,
         configure_cppflags, configure_cflags, configure_ldflags) = \
            get_config_vars('CC', 'CXX', 'CFLAGS',
                            'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS',
                            'CONFIGURE_CPPFLAGS', 'CONFIGURE_CFLAGS', 'CONFIGURE_LDFLAGS')

        if 'CC' in os.environ:
            newcc = os.environ['CC']
            if (sys.platform == 'darwin'
                    and 'LDSHARED' not in os.environ
                    and ldshared.startswith(cc)):
                # On OS X, if CC is overridden, use that as the default
                #       command for LDSHARED as well
                ldshared = newcc + ldshared[len(cc):]
            cc = newcc
        if 'CXX' in os.environ:
            cxx = os.environ['CXX']
        if fnmatch.filter([cc, cxx], '*-4.[0-8]'):
            configure_cflags = configure_cflags.replace('-fstack-protector-strong', '-fstack-protector')
            ldshared = ldshared.replace('-fstack-protector-strong', '-fstack-protector')
            cflags = cflags.replace('-fstack-protector-strong', '-fstack-protector')
        if 'LDSHARED' in os.environ:
            ldshared = os.environ['LDSHARED']
        if 'CPP' in os.environ:
            cpp = os.environ['CPP']
...
        compiler.set_executables(
            preprocessor=cpp,
            compiler=cc_cmd,
            compiler_so=cc_cmd + ' ' + ccshared,
            compiler_cxx=cxx,
            linker_so=ldshared,
            linker_exe=cc,
            archiver=archiver)

(You would then have to trace down set_executables and so forth if we wanted to understand the whole process, but I think we have our answer)

So you need to use export CXX=CC to get C++ compiler set. Setting cc will cause C to compiler with the specified compiler but leave c++ with the default according to the code.

Using gcc

You shouldn't have any issue using gcc so long as your Python was also compiled with the same compiler tools. Mixing and matching usually gives less that desirable results as ABIs do not mix unless they are pure C code. Of course that depends on figuring out how to get Python to compiler with a different compiler.

krowvin commented 2 years ago

I wanted to let you know I was able to get this to compile on Solaris. I ended up having to get cc installed. Eventually I needed another package installed on the system and it wound up in IT while I waited for them to install it. I tried again today and was able to compile and import Jpype!

Thank you for all your help Thrameos!