I'm using the eclipse IDE with MinGW as my compiler, to make a Win32 GUI app.
I want to get rid of the console, but compiling the program with -mwindows option has no effect and the console is still there.
Using the -Wl,--subsystem,windows flag also produces no effect. What am I doing wrong ?
For gcc on Windows, two things should be considered to build a non-console Windows app:
Compiler option -mwindows
Have WinMain()
It is possible, however, to manually specify -Wl,-subsystem,windows to the linker and include gdi32 and comdlg32 into the build. This is exactly what -mwindows automates.
Reference.
try --machine-windows option. it helps me when I build asm code:
nasm -f win64 hello.asm
gcc hello.obj --machine-windows -o hello
Related
I'm developing c++ code on Visual Studio 2019 (Version 16.5.4), and for the build i'm targeting Linux Ubuntu 18.04 with gcc 7.5 - both on a remote machine via ssh, and on my local machine via WSL2.
In both cases i have the same problem:
when using std::async, i have to add the compilation flag -lpthread to gcc's input, in order for the program to compile, otherwise i get
undefined reference to pthread_create
Moreover, the flag has to come after the cpp file name, i.e. g++ -lpthread xxx.cpp will fail with gcc 7.5, while g++ xxx.cpp -lpthread works fine.
so far so good, but here's the problem: i can't do a successful build through Visual Studio: when i add the -lpthread flag under Additional Options in the project's C/C++ properties, there doesn't seem to be any effect - the compilation still fails. moreover, since i don't see the flag being added to the full build command line (which is presented read-only), i have no way to see if the flag is actually being sent, and in the right order (namely after the cpp file name). since i don't see any way to manually edit the build command line, I'm out of ideas...
anyone?
Thanks.
I can compile a C++ code from ubuntu terminal with lapack library as
$g++ -lstdc++ -o fast_solver fast_solver.cpp -llapack
My question is if I want to use Netbeans IDE to compile the same code how do I configure Netbeans? More specifically, how do I ask Netbeans to compile with -lstdc++ and -llapack options?
Thank you in advance.
Best,
Geek
All you need (including compilers) comes in that NetBeans IDE package.
I would suggest that you read this guide which will show you how to create a new project and run code.
Its pretty easy.
In NetBeans IDE press F1 for more documentation.
Here's the question:
I wrote a piece of code on Windows. When using /MT option, the answer is wrong. When simply switching to /MTd, the answer is correct.
Now I'm transplanting porting this code to Linux. The answer is wrong using the following command: g++ -Ofast -o test test.cpp. Also, I'm quite sure that this is the only problem left.
I've installed libc6, libc6-dbg, libc6-dev, libstdc++-4.8-dev, libstdc++6 and libstdc++6-4.8-dbg.
What's the problem in this situation and how can I solve it?
Update: Problem solved. Codes can run on Windows (Debug and Release mode) and Linux correctly with various optimization options. There were variable initialization problems. Thanks everyone.
You need to fix your code. The program behaving differently with debug and release version of C++ runtime library (this is what is controlled by /MT and /MTd) means you have a bug in your program. Most likely undefined behavior.
The first thing would be change your compilation command to g++ -O3 -Werror -Wall -Wextra -pedantic -o test test.cpp and study compiler output. If you are lucky, you will see some warnings turned errors.
You have two problems.
Your g++ compile command is release mode. Use the -g option to compile with debug symbols.
You need to resolve on Windows why you don't get correct information in release mode with /MT.
I'm trying to set up ccache in Qt Creator on Windows.
Unfortunatelly I couldn't find any good instruction. How to make it working?
I have ccache installed with Cygwin.
edit:
I've tried adding
QMAKE_CXX+="ccache g++"
as additional parameter in qmake build step.
But in compile output I still have "g++ -c -g -Wall ..." and I suppose it should be "ccache g++ ..."
It should be:
"QMAKE_CXX=ccache g++"
And you might need to rerun qmake from the Build menu if QtCreator doesn't update automatically the makefile after you add that parameter.
QtCreator doesn't know about ccache, and besides, it's looking for trouble to mix Cygwin binaries with native binaries on Windows.
I want to install Clang compliler on my system. I went to this link, but so many download options out there confused me, as to which version should I download?
I'm using Dell's laptop : Windows 7 Basic 64-bit. I've already installed MinGW version 4.5.0. I've also installed Visual Studio 2008 as well as 2010.
What do you think is the best choice for me? Which Clang should I download? How should I configure it? I'm going to use Clang for the first time. So suggest me the best options!
By the way, can I configure Clang (or Visual Studio) so that Visual Studio may use Clang compiler to compile my C and C++ code?
EDIT:
What does it mean when the download page cryptically says "Front End Binaries for Mingw32/x86"?
You can use Clang with Visual Studio or MinGW. The choice is yours. But you'll need an external linker to produce Windows executables (MSVS's link.exe or MinGW's ld.exe/g++.exe).
If you want to use MinGW, download the next to last item (frontend binaries to mingw).
You can also compile Clang/LLVM from source, for that see here. This allows you to try out MSVS or MinGW(-w64). You'll need CMake for the build process.
UPDATE: regarding your edit: the "frontend" description reflects either the fact that llvm can be used as a backend in a GCC compilation through llvm-gcc (google has loads of info on this) or the fact that Clang itself is unable to link your code together into an executable or library. You still need the system's linker as I described above.
Clang now started releasing Windows snapshot builds
None. Front End Binaries # Mingw32/x86 is close, but you explicitly mentioned Windows 7 Basic 64-bit
so to be very specific you'll avail 64-bit benefits. So you'll follow steps at http://clang.llvm.org/get_started.html#buildWindows You may get VS2012 Express and the string with CMake should be "Visual Studio 11 Win64" Select Release instead of the default debug configuration from the dropdown and then build. Tool-chains are tightly coupled hierarchy, and MS's indulgence in non-standard extensions was never up-to-date by any other vendor implementation. Till llvm libcpp completes MinGW-W64 is the closest libstdc++ that I got from http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/mingw-w64-bin_i686-mingw_20111220.zip/download Check for newer build at http://mingw-w64.sourceforge.net/ Following are my trial calls for Hi console app
clang++.exe -fno-ms-compatibility -fno-use-cxa-atexit -IC:\mingw\include\c++\4.7.0 -IC:\mingw\include\c++\4.7.0\x86_64-w64-mingw32 -IC:\mingw\include\c++\4.7.0\backward -IC:\mingw\include -c C:\Users\Vipul\Documents\Hello.cpp -o C:\Users\Vipul\Documents\Hello.o
ld.exe -oC:\Users\Vipul\Documents\Hello.exe C:\Users\Vipul\Documents\Hello.o -m i386pep -Bdynamic -Lc:\mingw\lib c:\mingw\lib\crt2.o c:\mingw\lib\crtbegin.o -lstdc++ -lmingw32 -lgcc_s -LC:\Windows\SUA\opt\gcc64\lib\gcc\x86_64-pc-interix6\4.6.0 -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 c:\mingw\lib\crtend.o
The parameters are set on one single occasion of configuring IDE setting for say Code::Blocks The libs to pass to ld linker are determined using -v along-with g++ as clang++ will try to link libc++ sources against VS2012 binaries. Using g++ rather than ld is easier but seldom fails with ld not found internally owing to close coupling of tool-chain by hardcoding tool locations within source.