cannot execute binary file error that I scpd to a different computer - g++

I scp'd a Unix executable file into my work computer and am receiving an error when trying to run it. If I type in:
./cmpDNA 4 5 0.3 > results/results4_5_0.3.txt &
where cmpDNA is my program, 4 5 0.3 are input parameters and results/results4_5_0.3.txt is my output file, this is the error I receive:
-bash: ./cmpDNA: cannot execute binary file
I compiled in on my OS X computer using g++ and made sure to include my -m32 for a 32 bit build as the target computer is 32-bit Ubuntu. Typing:
file cmpDNA
gets:
cmpDNA: Mach-O executable i386
So I'm not sure why it won't execute. I've been looking for awhile but I can't find any answers that solve my problem. All users have executable permissions as well. Here were all of my compile options if that helps:
g++ -Wall -std=gnu++0x -o cmpDNA -m32 files.cpp
Thanks!

Can not compile on OS X without using a cross compiler and run on Ubuntu. Here is the answer that I found:
Compiling C Program on OS X to Run on Ubuntu

Related

libgcc_s_dw2-1.dll is missing when compiling with "-static-libgcc -static-libstdc++"

I'm compiling a program using the following commands on Linux Debian based:
i686-w64-mingw32-g++ -c my_program.cpp
i686-w64-mingw32-g++ -static-libgcc -static-libstdc++ my_program.o
But when I try to run the program inside my Windows 7 VirtualBox I get the following error:
libgcc_s_dw2-1.dll is missing
Why it doesn't static import the dll on compilation time?
Thank you

g++ doesn't recognize the file format of a dll

I am on Windows, and I am using the version of g++ that comes with mingw-64. I have a file on my computer called lua51.dll. When I try to run the following command :
g++ -shared -fPIC -o stuff.dll -llua51 stuff.cpp
I get the following error:
C:/Program Files/LOVE/lua51.dll: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
make: *** [main] Error 1
How can I fix this? Please let me know if more information is needed; I am a complete beginner to compilation.
This is an issue you get when you try to include a 64-bit library when running a 32-bit version of g++ or even gcc.
I thought that that the version of g++.exe that comes with mingw-64 would produce 64-bit code, but it turns out this isn't true; it still only produces 32-bit code. In my case, lua51.dll is 64-bit, which is an issue since I was using the version of g++ that produces 32-bit code.
Instead, you need to use x86_64-w64-mingw32-g++.exe, which can be found in the same folder as g++.exe. This is the version of g++ that will produce 64-bit code.

How to make cmake identify correct version in centos 6 terminal?

After a very long and lengthy process of trying to get Emscripten going. I'm stuck trying to build fastcomp.
cmake .. -DCMAKE_BUILD_TYPE=Release
-DLLVM_TARGETS_TO_BUILD="X86;JSBackend" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DCLANG_INCLUDE_TESTS=OFF
It gives this error:
CMake Error at cmake/modules/CheckCompilerVersion.cmake:12 (message):
Host GCC version must be at least 4.8!
I've installed devtools 2 and actiavted the toolset.
gcc --version reads as using gcc 4.8.2, but it just won't go.
I've also tried:
export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc
export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++
export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp
What am I doing wrong?
I had this same problem until I recompiled a recent version of cmake with the newer version of gcc already "activated".
Then, with the CC, CXX and CPP environment variables also set to the appropriate paths, cmake then stopped giving that "Host GCC version must be at least 4.8!" error.

Objective C program Compilation and Execution

I am a newbie to Objective C programs. I'm learning to code from tutorialspoint.com
As mentioned therein I downloaded GNUstep (Windows).
First, installed the MSYS/MinGW System package and then core package.
After that followed the steps mentioned there. I created a simple program with name hello.m and Stored that in C drive (Snapshot 1)
I don't know the meaning of this command below but entered it:
$ gcc gnustep-config --objc-flags -L /GNUstep/System/Library/Libraries hello.m -o hello -lgnustep-base -lobjc
The error it shows is - sh: gcc: command not found
Please help with the same, to compile and run my first Objective C program
gcc is the compiler, the other parameters are for compiling objective-c code.
Apparently you have misconfiguration in MSYS/MinGW setup.
Check out following post which has alternative and easier solution for running gcc under Windows.

Yosemite, target deployement with gfortran

On OS X Yosemite, this works:
gfortran main.f90
But this:
MACOSX_DEPLOYMENT_TARGET=10.5 gfortran main.f90
yields to the error:
ld: library not found for -lcrt1.10.5.o
collect2: error: ld returned 1 exit status
Why?
gfortran has been installed from http://hpc.sourceforge.net/, file gfortran-4.9-bin.tar.gz .
I use MACOSX_DEPLOYMENT_TARGET=10.5 in order to create binaries that run on OS X from 10.5 to 10.10
I have the file /Developer/SDKs/MacOSX10.5.sdk/usr/lib/crt1.10.5.o
Maybe something related to statically linked binary: apple doc.
Edit:
This works:
MACOSX_DEPLOYMENT_TARGET=10.5 gfortran -o main -L/Developer/SDKs/MacOSX10.5.sdk/usr/lib main.f90
But is it the right way? Is it a problem that crt1.10.5.o is linked statically?
I solved this for compiling with gfortran by installing XCode command-line tools as described http://hpc.sourceforge.net
Not sure it will solve your problem.
Good luck.
Jon