I have a C program "main.c" that uses LAPACK and BLAS subroutines. It is working fine on Ubuntu, showing the right results on the terminal.
Since I am a Windows user, I use Cygwin environment. However, when I execute my program after compiling with gcc main.c -llapack -lblas -lgfortran or even gcc -std=c99 main.c -llapack -lblas -lgfortran, nothing is showing on the terminal, although there are no compilation errors.
Does anyone have an idea what would be the problem?
Thank you.
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 installed the latest version of MinGW and trying to compile the project:
\MinGW\bin\gcc.exe -O3 -flto -Wall -msse src/*.c -o noname -lm -lpthread
But nothing happens. No errors, no exe files, nothing.
I am not familiar with Windows in terms of compilation.
This is a simple console application that is compilable on Ubuntu without problems with the same command.
What I am doing wrong?
I have a perfectly working C program using SDL that I can compile with
gcc main.c -o program `sdl-config --libs` -lSDL
The program is simple, it comes up with a black window and waits for the user to close it. No problems or errors. I have MinGW installed and I'm trying to use x86_64-w64-mingw32-gcc to cross-compile it; I would like to know how to cross-compile this for Windows on Linux and include the necessary libraries.
You can invoke MinGW’s GCC like your Linux version, but you might need to replacesdl-config with some manual configuration like so:
x86_64-w64-mingw32-gcc -Ipath/to/SDL/headers \
-Lpath/to/SDL/libs \
-o program main.o \
-lSDL -lSDLmain
You will need to download SDL.lib and SDLmain.lib. I believe they are part of the development zip. (Edit: as noted in the comments, you might not need to use the libs but can just use the DLLs.)
This might pop up a console window when running. Pass in the -mwindows flag to target the Windows subsystem instead.
I am working on a program which uses ncurses which will be used on embedded systems. Since these systems won't have ncurses installed I need to statically link the library. However if I try to build it like this
gcc -static ncurs.c -o ncurs -l:libncurses.a
or
gcc -static ncurs.c -o ncurs -lncurses
I get a ton of errors like this:
(.text+0x48): undefined reference to `SP'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_slktouch.o): In function `slk_touch':
normal compilation works fine.
I have searched for hours but I can't find any good information...
platform of development is stripped down debian system.
I guess you may need additional library, can you try -lncurses -ltinfo.
You can check on your system what the linker library flags for ncurses using command
pkg-config --static --libs ncurses
on my system, I got
-lncurses -ltinfo
try adding -ltinfo to the end of your commandline
I am trying to compile a windows .c file on linux using the following command:
wine gcc.exe x.c -o x.exe -lws2_32
And I get this error.
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain#16'
However, when using gcc.exe with the -shared attribute, the error gone.
wine gcc.exe -shared x.c -o x.exe -lws2_32
I tried viewing the help page of gcc.exe but can not find anything related to "-shared" argument
What does this argument do ?
-shared will make a shared object from the code, rather than an executable.
An executable would need a main function as an entry point, hence the undefined reference error you saw.
The shared object can be linked with other objects to make an executable.
See here or here
You first line is actually almost correct. (Doctorlove told you that shared is for making shared objects, libraries, which is true.)
You have to add:
wine gcc.exe -mwindows x.c -o x.exe -lws2_32
The -mwindows option is to tell GCC that you want to link a graphical Windows program, not a console program. Of course, your program must also contain a main() or WinMain() function, or you will get the same error message again.
As a side note, you may want to know that you don't have to use wine to cross compile with Mingw. There are mingw cross compilers for Linux. On Debian and Ubuntu you install it with apt-get install mingw32.