I'm trying to develop client in C for ActiveMQ using OpenWire and after compiling example main for OpenWire ActiveMQ on Ubuntu, when I try to run it I get this error:
bash: ./test: cannot execute binary file: Exec format error
I've tried it on both ubuntu 32 and 46 bit but it didn't work
Any Ideas?
Is there any other C alternative then OpenWire?
The problem is the -c flag, as it tells gcc to generate an object file and not an executable file.
Remove the -c flag:
gcc main.c -o test
Related
I am trying to use a grsecurity gcc plugin that I found on their unofficial linux kernel source tree (the respectre_plugin/ one).
My GCC version is 4.7, I modified scripts/gcc-plugins/Makefile to make it compile the plugin, and I built it with the root Makefile using make gcc-plugins, that shows no error.
Then, when I try to compile a C file that has a Spectre-like flaw, I got the following build error:
file.c:36:31: error: array_index_mask_nospec is not defined
This function is defined in respectre_plugin/respectre_plugin.c, and I have no idea why I've got this strange build error, if anyone knows about it...
My build invocation is the following:
gcc -Wall -Wextra -std=c99 -fplugin=/path/to/respectre_plugin.so -c file.c -o file.o
Thanks for any help !
I'm running on OSX and trying to compile following c code to webAssembly:
void test(){
//do stuff
}
I've looked at this example and tried running the following commands:
clang -emit-llvm --target=wasm32 -Oz test.c -c -o test.bc
llc -asm-verbose=false -o test.s test.bc
First command works fine and clang generates the .bc file, but when I try to run the second command I get:llc: : error: unable to get target for 'wasm32', see --version and --triple.
Any help would be appreciated.
It looks like your version of llvm was not compiled with support for the WebAssembly backend. This backend is still experimental so you need to enable it at cmake time with:
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
Firstly, my problem is similar to this: Ubuntu says "bash: ./program Permission denied"
However, I feel the need to further clarify.
When I compile my program using:
gcc -c file.c -o file
and run
./file
I get this error:
bash:./file: Permission denied
When I use
chmod u+x file
and then run
./file
I get this error:
bash: ./file: cannot execute binary file: Exec format error
However, when I compile using
gcc file.c -o file <br/>
My program runs perfectly well using
./file
Can someone point out what is the problem with using the -c argument with gcc?
Type gcc --help to see some help.
-c Only run preprocess, compile, and assemble steps
This means that, when run with this option, GCC doesn't link the executable with any (even system) libraries.
In short, to run a program, the OS needs a starting point, which is located in some system library. Since in your case GCC isn't linking the executable with anything, the OS doesn't know how to run the file, where to start.
I'm following the steps of the online book: "Learn C The Hard Way", and since I'm using Windows 7, I've installed Cygwin to use the Linux commands. But I'm facing a problem just on the first exercise of the book. I'm supposed to put the following command on the shell:
$ make ex1
After creating a ex1.c file on the folder. The command should give me:
cc ex1.c -o ex1
But instead, I'm getting the following message:
$ make ex1
cc ex1.c -o ex1
process_begin: CreateProcess(NULL, cc ex1.c -o ex1, ...) failed.
make (e=2): The system cannot find the specified file.
make: *** [ex1] Error 2
What's wrong?
First of all you should know that you should be running the command in the same directory where the file is. In cygwin, first you will have to locate to the folder in which the file is present, then you can run these make commands. Better since you are using Windows. You should better use any other windows based client for C. But if I were at your place. I would have installed a virtual Linux environment on my local windows computer and would have worked on that. You should try that once. Linux Terminal gives a lot of power to the developer. There are a lot of things which you can do on a terminal which is not supported by cygwin. For compiling C programs on Cygwin, I believe you should check if it supports compiler commands or not. :)
Make is reporting that it can not find cc.
cc is a link to gcc, and it belongs to gcc-core.
$ cygcheck -f /usr/bin/cc
gcc-core-5.4.0-1
To verify if the package is correctly installed
$ cygcheck -c gcc-core
Cygwin Package Information
Package Version Status
gcc-core 5.4.0-1 OK
If, as likely, the package is missing, you need to install it with the cygwin setup.
When compiling my program in 32bit using
gcc -m32 program.c -o program
I get the following error fatal error: sys/socket.h: No such file or directory
but with
gcc program.c -o program
it works fine
Is there any workaround for this?
my personal similar problem was solved as below:
by the way I am using cygwin.
The reason behind this error is trying to compile a unix c socket example in a window environment.
If you want to use windows, I think you should have cygwin installed with all the libraries needed for compiling c programs ;"gcc is the one used for generated Your_program_in_exe ".
Then start with compiling the server the server.follow this tutorial to understand about the basic of sockets.
You should have a client and a server programs.then go(using cd command) to the directory where you stored your code and perform the commands:
1- gcc socket-Server.c -o server to generate the execution file for the server.
this will generate server.exe file which will allow you to use ./server.exe to run the sever on your PC.if there is no error in your file you should have the .exe file in the your directory.
2- gcc socket-client.c -o client to generate the execution file for the client. This will generate the file client.exe file which allows you to execute the client.if there is no error u should have the client.exe together with ur server.exe in the file directory.
the screen capture below shows the commands i used and the basic output