conan-darwin-toolchain icon indicating copy to clipboard operation
conan-darwin-toolchain copied to clipboard

Profile for iOS simulator

Open rohan-elear opened this issue 5 years ago • 11 comments

I am trying to build some libraries using .configure but I am getting this error while trying to build it for iPhone Simulator for macOS.

Following is my profile:

include(default)

[settings]
os=iOS
os.version=11.0
arch=x86_64

[build_requires]
darwin-toolchain/1.0.4@theodelrieu/stable

build in conanfile.py

autotools = AutoToolsBuildEnvironment(self)
self.run("cd .. && autoreconf -fsi")
autotools.configure(configure_dir="..", args=["--prefix=${PWD}"])
autotools.make()

error while building for iOS simulator

configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
ERROR: conanfile.py (meshlink/None): Error in build() method, line 17
        autotools.configure(configure_dir="..", args=["--prefix=${PWD}"])
        ConanException: Error 1 while executing ../configure '--prefix=${PWD}' '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libexecdir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' '--datarootdir=${prefix}/share' --build=x86_64-apple-darwin --host=x86_64-apple-darwin

rohan-elear avatar Dec 09 '19 18:12 rohan-elear

I had this issue with some library also. It is most likely due to --host and --build having the same value.

Could you try autotools.configure(..., host="x86_64-apple-ios")?

theodelrieu avatar Dec 09 '19 20:12 theodelrieu

That did not work as well. If I change the profile to exclude the build_requires section, then it works but I am yet to test the binary on the simulator.

rohan-elear avatar Dec 10 '19 06:12 rohan-elear

If you can share the recipe, I'll be able to reproduce the issue

theodelrieu avatar Dec 10 '19 09:12 theodelrieu

If you can share the recipe, I'll be able to reproduce the issue

https://github.com/elear-solutions/meshlink/blob/elear-master/conanfile.py

rohan-elear avatar Dec 10 '19 19:12 rohan-elear

Adding host="x86_64-apple-ios" fixes the first issue on my machine, but it fails later on with catta:

=== configuring in catta (/tmp/meshlink/build/catta) configure: WARNING: no configuration information is in catta /Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive Making all in catta make[2]: *** No rule to make target `all'. Stop. make[1]: *** [all-recursive] Error 1

theodelrieu avatar Dec 11 '19 09:12 theodelrieu

for now I have written a _targets method to filter the target as per the input from conan

rohan-elear avatar Dec 17 '19 17:12 rohan-elear

And did it fix your issue?

theodelrieu avatar Dec 18 '19 08:12 theodelrieu

yeah sorry was busy applying the fix on all the conan files, yeah basically I wrote a lookup table by using the function to determine the host. That fixed the issue for now, maybe you can put this on your backlog :) thanks for all the help

rohan-elear avatar Jan 22 '20 20:01 rohan-elear

I have trouble building libjpeg from conan-center for simulator. it is using autotools. curiously I found a very simple script that actually works here. is it possible to teach conan to do that using this profile?

maddanio avatar Jan 27 '20 22:01 maddanio

@maddanio I've had the same error, which is unfortunately quite common with the AutoToolsBuildEnvironment helper. The thing is that it guesses the host wrong, and gives the same value to both --build and --host (i.e. x86_64-darwin-apple, instead of x86_64-darwin-ios).

You can override the default value by calling env_build.configure(..., host="x86_64-darwin-ios"). I will open an issue to Conan about the helper, I had this problem several times in my recipes.

EDIT: For some reason, I've only understood now that this is likely a Conan problem...

theodelrieu avatar Jan 28 '20 09:01 theodelrieu

The workaround I use to enable mutliple profile builds using the same file.

class libConan(ConanFile):
@property
    def _targets(self):
        return {
            "iOS-x86-*": "i386-apple-ios",
            "iOS-x86_64-*": "x86_64-apple-ios"
        }
    def config_options(self):
        args = ["--prefix=${PWD}"]
        return args
    def build(self):
        autotools = AutoToolsBuildEnvironment(self)
        args = self.config_options()
        self.run("cd .. && autoreconf -fsi ")
        query = "%s-%s-%s" % (self.settings.os, self.settings.arch, self.settings.compiler)
        ancestor = next((self._targets[i] for i in self._targets if fnmatch.fnmatch(query, i)), None)
        if not ancestor:
            autotools.configure(configure_dir= "..",args= args, use_default_install_dirs=True)
        else:
            autotools.configure(configure_dir= "..",args= args, use_default_install_dirs=True, host= ancestor)

rohan-elear avatar May 17 '20 10:05 rohan-elear