Can anyone point me to simple beginner-level instructions on how I can compile CURL so that it will compile OK on my 64-bit host PC?
I want to run c++ on my BBB Revision C, and have set up to cross-compile from an Ubuntu Virtual machine (14.04LTS running on a 64-bit host) as demonstrated in Derek Molloy’s excellent video.
I’ve made a lot of progress - but have completely failed in trying to install and run CURL.
From within Eclipse (3.8), I have built a trivially simple project
#include
#include <curl/curl.h>
using namespace std;
int main(){
return
}
but trying to Build this produces compilation errors:
/usr/include/curl/curlrules.h:143:41: error: size of array ‘curl_rule_01’ is negative
/usr/include/curl/curlrules.h:153:53: error: size of array ‘curl_rule_02’ is negative
which I gather comes down to a 64-bit vs 32-bit problem
I did try a manual fix, changing definitions in curlbuild.h like this:
CURL_SIZEOF_LONG 4
CURL_SIZEOF_CURL_OFF_T 4
but then I get the error
/usr/lib/x86_64-linux-gnu/libcurl.so: file not recognized: File format not recognised
Ideas, please.
John Geddes
Ubuntu Virtual machine (14.04LTS running on a 64-bit host)
First off, which distro are you using on the BBB ? Then which ABI are you compiling for, and which ABI are you actually using ? Secondly, if you’re using a virtual machine host architecture does not matter in this context. What matters is the virtual machines architecture. Is the virtual machine i386, or x64 ?
http://stackoverflow.com/questions/14404445/g-throwing-file-not-recognized-file-format-not-recognized-error gives a possible cause. Which is one reason why I use i386 host for cross compiling. However . . .http://eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-ARMCrossCompiler:GCC if we read this, we can get an idea of which packages we need for cross compiling on an x64 host.( assuming your VM is also x64 ).
A suggestion to you though. If you’re having to use a virtual machine already, why not just make the virtual machine i366? I can understand if you have like 16-32GB RAM on the host, and you want to get more than 4GB ram to the virtual machine I suppose. But honestly I do not think you’ll gain much performance. Unless perhaps you’re setting up a large RAMDISK . . . Anyhow, if you have a huge time investment into your VM ( setup and whatnot ) Disregard what I’m saying here.
First off, which distro are you using on the BBB ?
Latest Debian (http://debian.beagleboard.org/images/BBB-eMMC-flasher-debian-7.5-2014-05-14-2gb.img.xz)
Then which ABI are you compiling for, and which ABI are you actually using ?
Sorry - only a beginner. I don’t know where to look - suggestions, please
Secondly, if you’re using a virtual machine host architecture does not matter in this context. What matters is the virtual machines architecture. Is the virtual machine i386, or x64 ?
When I wrote, I was using an x64 virtual machine, but I have now (thanks to your assurance that host architecture in a VM is independent of the physical machine) started again with i386
But still I hit problems - when trying to compile project “JG1” using eclipse, I now get this:
Building target: JG1
Invoking: GCC C++ Linker
arm-linux-gnueabihf-g++ -o “JG1” ./src/JG1.o -lcurl -L/usr/lib/i386-linux-gnu
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/…/…/…/…/arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/i386-linux-gnu/libcurl.so when searching for -lcurl
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/…/…/…/…/arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/i386-linux-gnu/libcurl.a when searching for -lcurl
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/…/…/…/…/arm-linux-gnueabihf/bin/ld: cannot find -lcurl
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/…/…/…/…/arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/i386-linux-gnu/libm.so when searching for -lm
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/…/…/…/…/arm-linux-gnueabihf/bin/ld: skipping incompatible /usr/lib/i386-linux-gnu/libm.a when searching for -lm
collect2: error: ld returned 1 exit status
make: *** [JG1] Error 1
Any ideas of where I have gone wrong?
Ya, the BBB has nothing to do with i386. SO why is it trying to compile with i386 object files ? You need to learn how to setup a proper cross compile toolchain. . . .
Unfortunately, there seems to be no exact steps guide how to achieve this, and I honestly do not have the time to teach anyone “step-by-step” cross compiling. So, I recommend that you pick up a book on gcc toolchains, and start reading. It will take time to absorb this information, but it is something everyone must do to fully understand what they’re doing.
Once you do understand things more clearly, then perhaps you’ll be able to google and read about cross compiler setups, and pick out bits, and pieces of information that will apply for your own situation.
I was beginning to come to the conclusion that the idea of a non-Linux person “dipping in” to learn just enough to do the basics for C++ on BBB is impossible.You have confirmed this - I appreciate your advice.
There is great temptation to try and dip in - Derek Molloy’s BBB/C++ video seems to offer nice simple steps to do the basics, but then you hit something that you need that he doesn’t cover (CURL for example) and immediately you are in very scary territory. Back to Arduino, (or at best, bonescript), I fear.
Why can't you build it on the BBB?
"cross-compiling" is just a self imposed headache no one really has to
deal with..
Regards,
John, it’s not necessarily impossible, but you should really understand what you’re doing. Also, I’m still learning some myself, and what I mean by this is that you do not have to understand 100% of it all to achieve certain goals. For your case here however, I think you need to understand how the compiler, linker work together, and how to setup the toolchain to use the correct libraries / shared object files.
So getting a good book on GCC ( as in the toolchain ), then reading it will give you a very good start on that. Not only this, but knowing this information will help you with using any gcc toolchain. Not just for this specific case.
These listed below may help you understand enough:
ftp://gcc.gnu.org/pub/gcc/summit/2003/Building%20and%20Using%20a%20Cross%20Development%20Tool%20Chain.pdf
http://simplemachines.it/doc/toolchHOWTO.pdf
Also, sometimes ( very often ) you can google your exact error message that gcc spits out and at least glean enough information on how to fix your problem. Of course understanding you toolchain, and having hand on experience with how to google various kinds of errors helps. Sometimes, you can just paste part of the error message and find an exact explanation to a fix. This however does not mean finding the very last error on the command line output will help. This means, you need to go back up as far as you can to find the first inkling of an error.
There used to be a few good GNU gcc toolchain books online for free I thought, so if i happen to run across these again, I’ll shoot you a link in here.
Oh, and what Robert says is very true, but sometimes you may not want to compile natively on the BBB. The kernel for instance may drive you insane waiting for it to finish.
Hi William Hermans,
I am also facing the same problem what you faced. After doing the below things I am also getting the same error. Kindly guide me how you solve your problem. How you cross compile libcurl.
I did try a manual fix, changing definitions in curlbuild.h like this:
CURL_SIZEOF_LONG 4
CURL_SIZEOF_CURL_OFF_T 4
but then I get the error
/usr/lib/x86_64-linux-gnu/libcurl.so: file not recognized: File format not recognised
Kindly guide me. I want to use HTTP post using curl in beagle bone black device.
email id: das.shrabani@gmail.com