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

building with clang 15 on OSX #609

Closed
jkhoogland opened this issue Sep 27, 2022 · 2 comments
Closed

building with clang 15 on OSX #609

jkhoogland opened this issue Sep 27, 2022 · 2 comments
Labels

Comments

@jkhoogland
Copy link

Hi,
I use javacpp to build a java wrapper around a c++ library.
With the standard apple clang everything builds fine.

When I tried building using clang 15.0 on OSX, it fails out with the following message:

jnilibrary.cpp:66:29: error: 'TARGET_OS_IPHONE' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#if defined(__ANDROID__) || TARGET_OS_IPHONE
                            ^
1 error generated.

I tried to insert a line in the preset file to define TARGET_OS_IPHONE but that did not help.

define = {
    "TARGET_OS_IPHONE 0"
    },

There is some SO answer which suggests to include

#include <TargetConditionals.h>

but I am not sure where I would put that as this seems something deep inside the javacpp magic.

Did anybody hit this problem and find a fix ?

@wabscale
Copy link
Contributor

I believe this may be because the jnilibrary.cpp file that is generated has this near the top:

#include <jni.h>

#ifdef __ANDROID__
    #include <android/log.h>
#elif defined(__APPLE__) && defined(__OBJC__)
    #include <TargetConditionals.h>
    #include <Foundation/Foundation.h>
#endif

My guess is that on MacOS, if you brew install llvm and get the non-apple version of clang the __OBJC__ is undefined.

wabscale added a commit to wabscale/javacpp that referenced this issue Sep 27, 2022
wabscale added a commit to wabscale/javacpp that referenced this issue Sep 27, 2022
@saudet saudet added the bug label Sep 27, 2022
wabscale added a commit to wabscale/javacpp that referenced this issue Sep 28, 2022
@saudet
Copy link
Member

saudet commented Nov 3, 2022

The fix for this has been released with JavaCPP 1.5.8. Thanks for the contribution!

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

3 participants