Cross-compiling and CMake

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite
2












I am trying to cross-compile CGAL on an amd64 Linux machine to the ARM architecture. CGAL uses CMake for building.



CGAL has several dependencies, including GMP and MPFR libraries. When CMake runs, it needs to determine the versions of these dependencies. To find the versions, CMake compiles and runs several small test programs that simply link with these libraries and output their versions. This works fine during a regular, non-cross-compiled build.



But when I cross-compile, naturally these test programs will not run on the host machine. Here's an example:



/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
/opt/Company/ArmTools_GCC435_GLIBC_Q3_2011/bin/arm-rc-linux-gnueabi-g++ -fPIC CMakeFiles/cmTryCompileExec.dir/print_GMP_version.cpp.o -o cmTryCompileExec -rdynamic /home/pmw/Software-Engineering/build/Lib/mpir-2.6.0/arm/lib/libgmp.a
gmake[1]: Leaving directory `/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp'
/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: /home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: cannot execute binary file

-- USING GMP_VERSION = 'unknown'


I found a suggestion (if I understand it correctly) to specify the GMP version explicitly; that should keep CMake from trying and failing to determine it. So I created a file containing this line:



SET(GMP_VERSION 2.6.0)


and invoked CMake with the argument -C path/to/my/file. But that didn't change anything. Then I tried invoking CMake with the argument -DCMAKE_TOOLCHAIN_FILE=/path/to/my/file instead. Again, no effect. I see that CMake is able to find and parse this file, however.



So, how can I convince CMake to not try to build and execute cross-compiled programs on the host machine?



I apologize in advance if this Unix & Linux StackExchange site is not the best place for this question. Last week I posted my question on the CGAL mailing list (which is now the top three Google results for "cross-compiling cgal"; I am famous!) but received no replies.










share|improve this question





















  • I suggest posted a small self-contained example of a script that is failing.
    – Faheem Mitha
    Dec 5 '13 at 9:11










  • As a quick hack try setting set(CMAKE_C_COMPILER_WORKS 1) to suppress other compiler checks. Also inform Cmake that you are cross compiling by setting SET(CMAKE_CROSSCOMPILING 1)
    – Thushi
    Oct 14 '16 at 6:36














up vote
5
down vote

favorite
2












I am trying to cross-compile CGAL on an amd64 Linux machine to the ARM architecture. CGAL uses CMake for building.



CGAL has several dependencies, including GMP and MPFR libraries. When CMake runs, it needs to determine the versions of these dependencies. To find the versions, CMake compiles and runs several small test programs that simply link with these libraries and output their versions. This works fine during a regular, non-cross-compiled build.



But when I cross-compile, naturally these test programs will not run on the host machine. Here's an example:



/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
/opt/Company/ArmTools_GCC435_GLIBC_Q3_2011/bin/arm-rc-linux-gnueabi-g++ -fPIC CMakeFiles/cmTryCompileExec.dir/print_GMP_version.cpp.o -o cmTryCompileExec -rdynamic /home/pmw/Software-Engineering/build/Lib/mpir-2.6.0/arm/lib/libgmp.a
gmake[1]: Leaving directory `/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp'
/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: /home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: cannot execute binary file

-- USING GMP_VERSION = 'unknown'


I found a suggestion (if I understand it correctly) to specify the GMP version explicitly; that should keep CMake from trying and failing to determine it. So I created a file containing this line:



SET(GMP_VERSION 2.6.0)


and invoked CMake with the argument -C path/to/my/file. But that didn't change anything. Then I tried invoking CMake with the argument -DCMAKE_TOOLCHAIN_FILE=/path/to/my/file instead. Again, no effect. I see that CMake is able to find and parse this file, however.



So, how can I convince CMake to not try to build and execute cross-compiled programs on the host machine?



I apologize in advance if this Unix & Linux StackExchange site is not the best place for this question. Last week I posted my question on the CGAL mailing list (which is now the top three Google results for "cross-compiling cgal"; I am famous!) but received no replies.










share|improve this question





















  • I suggest posted a small self-contained example of a script that is failing.
    – Faheem Mitha
    Dec 5 '13 at 9:11










  • As a quick hack try setting set(CMAKE_C_COMPILER_WORKS 1) to suppress other compiler checks. Also inform Cmake that you are cross compiling by setting SET(CMAKE_CROSSCOMPILING 1)
    – Thushi
    Oct 14 '16 at 6:36












up vote
5
down vote

favorite
2









up vote
5
down vote

favorite
2






2





I am trying to cross-compile CGAL on an amd64 Linux machine to the ARM architecture. CGAL uses CMake for building.



CGAL has several dependencies, including GMP and MPFR libraries. When CMake runs, it needs to determine the versions of these dependencies. To find the versions, CMake compiles and runs several small test programs that simply link with these libraries and output their versions. This works fine during a regular, non-cross-compiled build.



But when I cross-compile, naturally these test programs will not run on the host machine. Here's an example:



/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
/opt/Company/ArmTools_GCC435_GLIBC_Q3_2011/bin/arm-rc-linux-gnueabi-g++ -fPIC CMakeFiles/cmTryCompileExec.dir/print_GMP_version.cpp.o -o cmTryCompileExec -rdynamic /home/pmw/Software-Engineering/build/Lib/mpir-2.6.0/arm/lib/libgmp.a
gmake[1]: Leaving directory `/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp'
/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: /home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: cannot execute binary file

-- USING GMP_VERSION = 'unknown'


I found a suggestion (if I understand it correctly) to specify the GMP version explicitly; that should keep CMake from trying and failing to determine it. So I created a file containing this line:



SET(GMP_VERSION 2.6.0)


and invoked CMake with the argument -C path/to/my/file. But that didn't change anything. Then I tried invoking CMake with the argument -DCMAKE_TOOLCHAIN_FILE=/path/to/my/file instead. Again, no effect. I see that CMake is able to find and parse this file, however.



So, how can I convince CMake to not try to build and execute cross-compiled programs on the host machine?



I apologize in advance if this Unix & Linux StackExchange site is not the best place for this question. Last week I posted my question on the CGAL mailing list (which is now the top three Google results for "cross-compiling cgal"; I am famous!) but received no replies.










share|improve this question













I am trying to cross-compile CGAL on an amd64 Linux machine to the ARM architecture. CGAL uses CMake for building.



CGAL has several dependencies, including GMP and MPFR libraries. When CMake runs, it needs to determine the versions of these dependencies. To find the versions, CMake compiles and runs several small test programs that simply link with these libraries and output their versions. This works fine during a regular, non-cross-compiled build.



But when I cross-compile, naturally these test programs will not run on the host machine. Here's an example:



/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
/opt/Company/ArmTools_GCC435_GLIBC_Q3_2011/bin/arm-rc-linux-gnueabi-g++ -fPIC CMakeFiles/cmTryCompileExec.dir/print_GMP_version.cpp.o -o cmTryCompileExec -rdynamic /home/pmw/Software-Engineering/build/Lib/mpir-2.6.0/arm/lib/libgmp.a
gmake[1]: Leaving directory `/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp'
/home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: /home/pmw/Software-Engineering/SW_Tools/CGAL-4.1/CMakeFiles/CMakeTmp/cmTryCompileExec: cannot execute binary file

-- USING GMP_VERSION = 'unknown'


I found a suggestion (if I understand it correctly) to specify the GMP version explicitly; that should keep CMake from trying and failing to determine it. So I created a file containing this line:



SET(GMP_VERSION 2.6.0)


and invoked CMake with the argument -C path/to/my/file. But that didn't change anything. Then I tried invoking CMake with the argument -DCMAKE_TOOLCHAIN_FILE=/path/to/my/file instead. Again, no effect. I see that CMake is able to find and parse this file, however.



So, how can I convince CMake to not try to build and execute cross-compiled programs on the host machine?



I apologize in advance if this Unix & Linux StackExchange site is not the best place for this question. Last week I posted my question on the CGAL mailing list (which is now the top three Google results for "cross-compiling cgal"; I am famous!) but received no replies.







cross-compilation cmake






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '12 at 23:19









Philip

17818




17818











  • I suggest posted a small self-contained example of a script that is failing.
    – Faheem Mitha
    Dec 5 '13 at 9:11










  • As a quick hack try setting set(CMAKE_C_COMPILER_WORKS 1) to suppress other compiler checks. Also inform Cmake that you are cross compiling by setting SET(CMAKE_CROSSCOMPILING 1)
    – Thushi
    Oct 14 '16 at 6:36
















  • I suggest posted a small self-contained example of a script that is failing.
    – Faheem Mitha
    Dec 5 '13 at 9:11










  • As a quick hack try setting set(CMAKE_C_COMPILER_WORKS 1) to suppress other compiler checks. Also inform Cmake that you are cross compiling by setting SET(CMAKE_CROSSCOMPILING 1)
    – Thushi
    Oct 14 '16 at 6:36















I suggest posted a small self-contained example of a script that is failing.
– Faheem Mitha
Dec 5 '13 at 9:11




I suggest posted a small self-contained example of a script that is failing.
– Faheem Mitha
Dec 5 '13 at 9:11












As a quick hack try setting set(CMAKE_C_COMPILER_WORKS 1) to suppress other compiler checks. Also inform Cmake that you are cross compiling by setting SET(CMAKE_CROSSCOMPILING 1)
– Thushi
Oct 14 '16 at 6:36




As a quick hack try setting set(CMAKE_C_COMPILER_WORKS 1) to suppress other compiler checks. Also inform Cmake that you are cross compiling by setting SET(CMAKE_CROSSCOMPILING 1)
– Thushi
Oct 14 '16 at 6:36










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Have a look at CMake wiki, I believe you need to fiddle a bit with the CMAKE_CROSSCOMPILING variable and CMake's cache (all described at the wiki).






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f56162%2fcross-compiling-and-cmake%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Have a look at CMake wiki, I believe you need to fiddle a bit with the CMAKE_CROSSCOMPILING variable and CMake's cache (all described at the wiki).






    share|improve this answer
























      up vote
      0
      down vote













      Have a look at CMake wiki, I believe you need to fiddle a bit with the CMAKE_CROSSCOMPILING variable and CMake's cache (all described at the wiki).






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Have a look at CMake wiki, I believe you need to fiddle a bit with the CMAKE_CROSSCOMPILING variable and CMake's cache (all described at the wiki).






        share|improve this answer












        Have a look at CMake wiki, I believe you need to fiddle a bit with the CMAKE_CROSSCOMPILING variable and CMake's cache (all described at the wiki).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '12 at 17:34









        peterph

        22.6k24356




        22.6k24356



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f56162%2fcross-compiling-and-cmake%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay