I am trying to compile 64-bit GSL on a Windows 7 machine. Here are the steps I took:
Downloaded and untarred the GSL 1.15 source found here.
Tested that I have a 64-bit version of GCC available in the Cygwin shell, by compiling the minimal program
// simple.C
int main() {
;
return 0;
}
using
x86_64-w64-mingw32-gcc -m64 simple.C -o simple
In the untarred folder, I would like to pass the x86_64-w64-mingw32-gcc compiler to ./configure but am not sure how. I took a look at the configure file, but that is huge and appears to have been generated using autoconf.
At the cygwin prompt you can use:
CC=x86_64-w64-mingw32-gcc CFLAGS=-m64 ./configure
and configure will pick it up.
Important Note:
I am surprised that you don't have a wrapper gcc ... Why don't you try using ./configure by itself just as is to begin with and see what it does before overriding the C compiler as I showed.
Related
I have a program written on Linux in GNU C. The program compiles with GCC. I have an install shell script,
gcc -o program program.c -Wall -pedantic -std=gnu11 -lm -fopenmp
which works greatly.
The problem is with Mac. For some reason, Mac sees gcc and instead uses clang even though GCC is installed and install.sh explicitly says gcc. clang doesn't work with omp.h The problem is that clang can't use omp.h and solutions offered http://releases.llvm.org/3.7.0/tools/clang/docs/ReleaseNotes.html#openmp-support don't work, and omp.h may not work in mac at all Enable OpenMP support in clang in Mac OS X (sierra)
I never use macs, and because of this nonsense I never plan to. However, some people using my program want to use Mac, so I have to deal with this.
I've tried various shell script modifications, but none of them work, mac insists on using clang and won't use gcc
I need to do one of two things which I don't know how to do:
1) force Mac to use gcc (which it refuses to do now)
2) get clang to use omp.h in mac (which from other answers on Stack Overflow, looks impossible)
Your second option (get clang to use omp.h) is not impossible (any more). From my answer here:
Try using Homebrew's llvm:
brew install llvm
You then have all the llvm binaries in /usr/local/opt/llvm/bin. To compile the OpenMP Hello World program, for example, type
/usr/local/opt/llvm/bin/clang -fopenmp -L/usr/local/opt/llvm/lib omp_hello.c -o hello
You might also have to set the CPPFLAGS with -I/usr/local/opt/llvm/include.
I know this question has been asked several times and I took a look at many of them like
Running linux gcc-compiled program under windows
How can I compile C files into an executable (.exe) file?
Unfortunately, none of them worked for me.
My situation
I've installed Ubuntu and Windows on my Notebook.
Let's say I developed a simple "Hello,World!"program using a text editor in c.
In Ubuntu, I've compiled it using GCC
$ gcc -o hello.out -g -Wall -pedantic hello.c
I executed it './output.out'
And got the result Hello, World!
What I tried
So I kind of cross-developed here. I switched to Windows and kept going.
Now, I try to make it an executable file in order to run it on Windows. I know Windows can't handle '$ ./output.out' , alright, let's make it an executable then.
Under Windows, I've
installed cygwin
In Cygwin, I compiled it using GCC
$ gcc -o hello.exe -g -Wall -pedantic hello.c
Note: I wrote hello.exe instead of hello.out or hello.c
In Cygwin, I executed it '$ ./output.exe'
And got the result Hello, World!
Note: At this point, it even works with my Shell under Windows because I installed Cygwin and set up my PATH etc. This means I can open my command line, go to the directory in which 'hello.exe' is located and execute it by typing '> hello.exe'
I thought that would be it, so I took hello.exe' and moved it to another notebook (not my local machine). I tried to execute it but it didn't work.
At first, I got an cygwin1.dll missing message. After fixing it, another error appears.
What I'm trying to accomplish
To make a long story short:
The reason I wrote so much is that I want to give you a detailed look of my situation.
Basically, I'm trying to create an executable c file, which any Windows User could execute without having any development tools.
In Eclipse and Java, you could simply export your program making it a runnable -jar file. All the User has to do is install the latest Java SE version to get it running.
Additionally, I tried to compile my program in Visual Studio but that didn't work either.
Any suggestions? Thanks a lot!
cygwin gcc produce an executable linked to the cygwin1.dll. So it is not usable without that.
gcc hello.c -o hello-cygwin.exe
$ ldd hello-cygwin.exe
ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x77bd0000)
kernel32.dll => /cygdrive/c/Windows/system32/kernel32.dll (0x77ab0000)
KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x7fefdc60000)
SYSFER.DLL => /cygdrive/c/Windows/System32/SYSFER.DLL (0x75650000)
cygwin1.dll => /usr/bin/cygwin1.dll (0x180040000)
If you need a standalone program, a solution is to use the mingw compiler
(it is available on cygwin as cross compiler to windows)
$ x86_64-w64-mingw32-gcc.exe hello.c -o hello-mingw64.exe
$ ldd hello-mingw64.exe
ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x77bd0000)
kernel32.dll => /cygdrive/c/Windows/system32/kernel32.dll (0x77ab0000)
KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x7fefdc60000)
SYSFER.DLL => /cygdrive/c/Windows/System32/SYSFER.DLL (0x75650000)
msvcrt.dll => /cygdrive/c/Windows/system32/msvcrt.dll (0x7fefdf40000)
You can move the resulting program on another windows machine that don't have cygwin installed.
You should use mingw which is the gcc port for windows instead of gcc under cygwin. You can get it here.
I'm using MinGW on Linux (Ubuntu, specifically) to compile a C program for Windows. I'm using a library called SFML, and it's bindings called CSFML. I'm using -L and -l to locate the libraries, but when I compile I get this error:
win32/dll/csfml-audio-2.dll: file not recognized: File format not recognised
I've got no idea why. Here's the command I'm using to compile:
sudo i686-w64-mingw32-gcc -o wandering src/main.c src/constants.c src/Display/display.c **...some more c files in here...** src/Generation/perlinnoise.c $(pkg-config --libs --cflags glib-2.0) $(pkg-config --libs --cflags gee-1.0) -Iwin32/CSFML-2.1/include -Lwin32/dll -lcsfml-audio-
Does anyone know why it's happening? I can compile C programs without SFML but with MinGW just fine...
The DLL has a PE32 executable file header. It's not used for the linker. You should use the import library instead. This file has the extension LIB.
I heard there are some gcc compiler versions out there than generate an import library from a DLL on the fly. It looks like your version doesn't.
From command line it seem's trying to use sudo i686-w64-mingw32-gcc 64 bit compiler and supplying 32 bit DLL i.e. win32/dll/csfml-audio-2.dll. change to x64/dll/csfml-audio-2.dll. It should work fine.
I am using Eclipse Kepler and running it under Win7 64-Bit. As compiler I use the gcc (4.8.1) from MinGW. Now I have the following problem:
//edit: Reformulated question to make it more clear
I have a project containing of one source-file with C-Code: main.c
This file can be compiled over 2 ways:
Start the compiler over the command-line: gcc -o main.exe main.c
Start the compiler over Eclipse by starting the normal build-routine (which also calls the gcc)
Now for some reason I want to add some C++-Code, but I still want to compile it with the gcc.
The gcc itself decides how to compile over the file extension - This means, if main.c contains C++-Code and I call gcc -o main.exe main.c it won't work. To make the compiler realize it's C++ I have to change the file-extension to somthing like .C or .cpp and then it will work.
Now back to Eclipse:
When I change my Sourcefile to main.C Eclipse interprets it as C++ File, meaning it changes the Code-Highlighting. When I now start a build process over Eclipse it just tells me
Info: Nothing to build for PROJECT
This means there is not even a call to the gcc-compiler. My guess is, that Eclipse somehow doesn't want to call the gcc, because the source-file is marked as C++-File.
//edit2: Just tried - when I have a C++-Projekt Eclipse just ignores the *.C or the *.cpp-files. I guess I have to add them manually, so they're built too ... but where?
The g++ is the compiler to compile C++ codes.
Change you compiler in you eclipse project.
When I compile a simple Hello World! program that uses the sscanf function on my local Debian lenny x64, it works. But when I upload the same program to the server running CentOS x86, it will not work. If I do not use sscanf, then the program works on both computers.
gcc -std=c99 -O2 -pipe -m32
If I compile it with sscanf but without -std=c99, then it works on both computers.
gcc -O2 -pipe -m32
What is the problem with sscanf and c99 on CentOS x86 ? I thought that compiling with the -m32 flag would work on all Linuxes ? (I have limited access to the CentOS server, so I do not have access to error messages.)
Probably the CentOS box is using an old version of glibc. Since the nonstandard GNU extensions to their scanf implementation ended up making glibc conflict with c99, they added a nasty hack of redirecting *scanf to __isoc99_*scanf when -std=c99 is in use; if your copy of glibc is missing the __isoc99_sscanf symbol, the program will then fail to run.
Static linking, or linking to a different libc without ugly backwardsness-compatibility hacks, would solve the problem.
Are you uploading the binary or the source and then recompiling? If you are uploading the binary, you are probably running into a library compatibility issue between Debian and CentOS.
If that is the case, upload the source only and recompile on CentOS.
If you do not have permission to compile # CentOS, then try compiling a static binary. You can use dietlibc which makes smaller binaries than glibc or try EGLIBC which is the default C library that Debian will use starting Debian "squeeze".
I came up with the similar problem, it works # Ubuntu 64-bit, but the compile fails # CenseOS 64-bit (REHL5 desktop):
the error message is:
undefined reference to `__isoc99_sscanf#GLIBC_2.7'
when i copied the executable file compiled #Ubuntu to REHL5, and run it another error appeared:
elf file os abi invalid
it is compiled without flag -std=c99, i'm a newbie at C, and looking forword some workarounds, ex. add some flag.
Makefile:
CC=gcc
CCFLAGS= -Wall -O2 -DLINUX -I../include
demos:linuxdemo.c
$(CC) $(CCFLAGS) -o demoA linuxdemo.c -L../lib -lsense4 -lusb
$(CC) $(CCFLAGS) -o demoSO linuxdemo.c -lusb -lsense4
clean:
rm -f demoA
rm -f demoSO
You need to update your glibc to 2.7
download the rpm package from here:
http://archive.fedoraproject.org/pub/archive/fedora/linux/releases/8/Everything/x86_64/os/Packages/
needs:
libc-common-2.7-2.x86_64.rpm
glibc-headers-2.7-2.x86_64.rpm
glibc-devel-2.7-2.x86_64.rpm
glibc-2.7-2.x86_64.rpm
command:
rpm -Uvh --aid --nodeps glibc-common-2.7-2.x86_64.rpm
rpm -Uvh --aid --nodeps glibc-headers-2.7-2.x86_64.rpm
rpm -Uvh --aid --nodeps glibc-devel-2.7-2.x86_64.rpm
rpm -Uvh --aid --nodeps glibc-2.7-2.x86_64.rpm