Change Output Directory in Dev C++ - dev-c++

I want to separate .c/.cpp files and .exe files in different folders.
How it's possible??
When I execute the code -
C++ Compiler: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe
Command: g++.exe "D:\C\init\pointers\String.cpp" -o "D:\C\init\pointers\String.exe" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc

Necromancy here, I know, but I've just found myself in the same situation.
I'm using Dev-C++ 5.11, the current up to date fork, not the original Bloodshed one.
Dev-C++ allow to directly compile cpp files but the option you're looking for is related to project options. You must create a new project, add your code and then you can find it under "Project Options" -> "Output" -> "Executable output directory".

Related

NMAKE: How do I force a debug build? [7ZIP]

The suggested way of building 7Zip is on the command line via the nmake command line utility. 7zip doesn't seem to come with a working visual studio solution.
I have seen invocations such as nmake NEW_COMPILER=1 MY_STATIC_LINK=1 suggested for initiating a build using the various nested .MAK files.
Using this command line interface how might I force a build with debug symbols?
If there is no standard way to accomplish this via nmake, I'd be glad to receive help with regards to 7Zip in particular. I am much less familiar with .MAK than GNU make, and have thus far been unable to find something akin to a "debug target" in the GNU make sense in 7ZIP.
To make a project that uses visual studio nmake build a debug output you need to edit the makefile and make 2 changes.
First you need to add /Zi to the list of flags used when compiling
CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -W4 -WX -EHsc -Gy -GR- -GF /Zi
Second you need to add /debug to list of options for the linker e.g.
LFLAGS = $(LFLAGS) -nologo -OPT:REF -OPT:ICF /DEBUG
I tested this on a different library, I assume there will be similarities here.
7zip archiver gives great compression and performance results, but unfortunately have lack of documentation nor for building process nor at the entire code.
I know that the question asked 1.5 yrs ago but I hope to save someone time for digging around in the 7z.
To build 7z from sources you need the Microsoft Visual Studio and do following steps:
Start Tools Command Prompt for VS 2019
Navigate to sources folder cd c:\sources\7z
Invoke nmake /f makefile
Otherwise you can convert MSVC 6.0 dsw/dsp files to modern .vcxproj format. Just open dsw file in the MSVC 2019 and it will do the conversion automatically.
The trick is that you need to navigate into project directory to do that. The 7z build system hard tied to relative directory structure and gets build parameters from top level main Build.mak file.
So, if you need to modify build parameters for all projects it is enough to modify that file.
For 7z version 19.00 you need to edit these lines in CPP/Build.mak file:
Add /Zi fag to line CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -W4 -WX -EHsc -Gy -GR- -GF /Zi
Add /DEBUG LFLAGS = $(LFLAGS) -nologo -OPT:REF -OPT:ICF /DEBUG
Change -O1 and -O2 for flags CFLAGS_O1 CFLAGS_O2
!IF "$(PLATFORM)" == "x64"
CFLAGS_O1 = $(CFLAGS) -Od
!ELSE
CFLAGS_O1 = $(CFLAGS) -Od
!ENDIF
CFLAGS_O2 = $(CFLAGS) -Od

CMake Gcov c++ creating wrong .gcno files

I have a CMakeLists.txt file in which I added:
set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage -pthread -std=c++11 -O0 ${CMAKE_CXX_FLAGS}")
It is generating the report files in:
project_root/build/CMakeFiles/project.dir/
BUT the files it generates have extentions .cpp.gcno, .cpp.gcda and .cpp.o.
Also, they are not in the same folder as the src files, which are at:
project_root/src/
When I move the report files to the src/ folder and execute
$ gcov main.cpp
main.gcno:cannot open notes file
But I get that error message. So I change the .cpp.gcno, .cpp.cdna and cpp.o to .gcno, .gcda and .o and finally I get the following:
gcov main.cpp
Lines executed:86.67% of 15
Creating 'main.cpp.gcov'
I have over 50 files and can't do this manually for each one.
I need to be able to run gcov once for all files and generate report for all files. I don't care where the files are generated.
It is generating the report files in: project_root/build/CMakeFiles/project.dir/
This is directory where all additional files are built for 'project' executable.
BUT the files it generates have extentions '.cpp.gcno', '.cpp.gcda' and '.cpp.o'
This is because CMake creates .cpp.o object file from .cpp source (you may see that running make VERBOSE=1. In accordance to -fprofile-arcs option's description, data file has suffix .cpp.gcno.
Also, they are not in the same folder as the src files
Data files are created in the same directory with object file.
Actually, created files are still work, if you call
gcov main.cpp.gcno
from the directory with .gcno files.
Apparently the standard CMake behavior to add an extension to give .cpp.o can be changed to replace an extension to give .o by using:
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE ON)

Dev-C++ Recipe for Target Failed

I have a problem that really is driving me crazy right now. I have a project written in C++ and it's using pthread. I've compiled this project with Dev-C yesterday and everything was just perfect. However, today, I'm getting this nonsense "recipe for target 'project1.exe' failed" error. I didn't change anything, how come this project got broken by itself? I really don't get it. Please help me. Compile error is below:
> General: TDM-GCC 4.8.1 64-bit Release Building Makefile
> "E:\2013-2014\[CNG 334] OS\Course Project\New folder\Makefile.win"
> Executing make... mingw32-make.exe -f "E:\2013-2014\[CNG 334]
> OS\Course Project\New folder\Makefile.win" all g++.exe -c main.cpp -o
> main.o -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include"
> -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64- w64-mingw32/4.8.1/include"
> -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32 /4.8.1/include/c++"
g++.exe -c v1withupperandlowerletters.cpp -o
v1withupperandlowerletters.o -I"C:/Program Files
(x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files
(x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files
(x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.8.1/include"
-I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32 /4.8.1/include/c++"
g++.exe main.o v1withupperandlowerletters.o -o Project1.exe
-L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc
E:\2013-2014[CNG 334] OS\Course Project\New folder\Makefile.win:25:
recipe for target 'Project1.exe' failed
mingw32-make.exe: *** [Project1.exe] Error 1
Compilation succeeded in 4.41 seconds
Thank you very much.
Edit: Problem resolved. You can check my answer below.
It turned out strangely that my firewall program's sandbox feature was blocking Dev-C to create a new file from a project even though Dev-C++ itself was marked as a trusted program. I've disabled the sandboxing feature and it's working perfect.
I'm not deleting this topic since this may help some other person in the future. I'm using Comodo firewall and maybe other firewalls out there with sandboxing feature may raise the same problem.

How to tell if a lib was compiled with /mt or /md?

Given a compiled lib, is there a way to tell if it was compiled with /md or /mt just by looking at it (maybe with dumpbin tool)?
Edit:
dumpbin /directives foo.lib is a solution for the case where the lib was not compiled with /GL switch. Is there an option to inspect a lib file that was optimized in such a way?
Yes, you could use dumpbin's /DIRECTIVES option to find which runtime libraries the objects in the .lib want to link with:
dumpbin /directives foo.lib
Look for instances of the runtime libraries specified here. For example, you might see:
/DEFAULTLIB:MSVCRTD (module compiled with /MDd)
or
/DEFAULTLIB:MSVCRT (module compiled with /MD)
or
/DEFAULTLIB:LIBCMT (module compiled with /MT)
There will probably be many /DEFAULTLIB directives, so you can search using terms like:
dumpbin /DIRECTIVES foo.lib | find /i "msvcr"
A very nice feature of the Microsoft compiler is that it preserves the command line that was used to compile a source file into the .obj file. Which allows you to find it back by looking at the .lib file with, wait for it, Notepad.exe. Just search for "cl.exe".
For example, this is what I see when I use Notepad opened on a sample library named Win32Project1.lib that I built with VS2013:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe cmd -c -ZI -nologo -W3 -WX- -sdl -Od -Oy- -DWIN32 -D_DEBUG -D_LIB -DHELLO_STACKOVERFLOW -D_UNICODE -DUNICODE -Gm -EHs -EHc -RTC1 -MDd -GS -fp:precise -Zc:wchar_t -Zc:forScope -Ycstdafx.h -Fp"c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\Win32Project1.pch" -Fo"c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\" -Fd"c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\vc120.pdb" -Gd -TP -analyze- -errorreport:prompt -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include" -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include" -I"C:\Program Files (x86)\Windows Kits\8.1\Include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\Include\shared" -I"C:\Program Files (x86)\Windows Kits\8.1\Include\winrt" -X src stdafx.cpp pdb c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\vc120.pdb
As you can tell, I compiled with /MDd
Do beware that a .lib can contain multiple .obj files with possibly different settings. Searching for "-mt" and "-md" lets you find out quickly.

How to add a library include path for NetBeans and gcc on Windows?

How to add a library include path for NetBeans and gcc on Windows?
Using:
NetBeans 7.1.2
MinGW (mingw-get-inst-20120426.exe)
gcc 4.7.0
For example, you want to add the directories in C:\Program Files (x86)\Example\1.0\include\ as the include paths.
First, set up code assistance:
NetBeans > Tools > Options > C/C++ > Code Assistance
C Compiler > Include Directories:
C:\Program Files (x86)\Example\1.0\include\shared
C:\Program Files (x86)\Example\1.0\include\other
C:\Program Files (x86)\Example\1.0\include
C:\MinGW\lib\gcc\mingw32\4.7.0\include
C:\MinGW\include
C:\MinGW\lib\gcc\mingw32\4.7.0\include-fixed
...
C++ Compiler > Include Directories:
C:\Program Files (x86)\Example\1.0\include\shared
C:\Program Files (x86)\Example\1.0\include\other
C:\Program Files (x86)\Example\1.0\include
C:\MinGW\lib\gcc\mingw32\4.7.0\include\c++
C:\MinGW\lib\gcc\mingw32\4.7.0\include\c++\mingw32
C:\MinGW\lib\gcc\mingw32\4.7.0\include\c++\backward
C:\MinGW\lib\gcc\mingw32\4.7.0\include
C:\MinGW\include
C:\MinGW\lib\gcc\mingw32\4.7.0\include-fixed
...
OK.
The C:\MinGW\... directories are examples only. Do not actually add them. NetBeans should have detected and added the MinGW directories automatically. If not, try resetting the settings:
NetBeans > Tools > Options > C/C++
Code Assistance
C Compiler > Reset Settings
C++ Compiler > Reset Settings
Build Tools
Restore Defaults
For instructions on automatic code assistance for existing sources, see:
C/C++ Projects Quick Start Tutorial:
http://netbeans.org/kb/docs/cnd/quickstart.html#makefileprojects
How to Configure Code Assistance When Creating a Project from Existing Code:
http://netbeans.org/kb/docs/cnd/configuring-code-assistance.html
Now, configure the project options:
Right click on project > Properties
Configuration: <All Configurations>
Build
C Compiler
General
Include Directories:
C:\Program Files (x86)\Example\1.0\include\shared
C:\Program Files (x86)\Example\1.0\include\other
C:\Program Files (x86)\Example\1.0\include
Compilation Line
Additional Options:
-std=c11 -g3 -pedantic -Wall -Wextra -O0
C++ Compiler
General
Include Directories:
C:\Program Files (x86)\Example\1.0\include\shared
C:\Program Files (x86)\Example\1.0\include\other
C:\Program Files (x86)\Example\1.0\include
Compilation Line
Additional Options:
-std=c++11 -g3 -pedantic -Wall -Wextra -O0
OK.
For adding command-line options by default for all projects, see:
NetBeans settings for GCC
Any spaces in the path should be automatically escaped. Any backward slashes should be replaced with forward slashes automatically.
For example, the "All options" textbox in "Additional Options" looks like this:
-std=c11 -g3 -pedantic -Wall -Wextra -O0 -g -I/C/Program\ Files\ \(x86\)/Example/1.0/include/shared -I/C/Program\ Files\ \(x86\)/Example/1.0/include/other -I/C/Program\ Files\ \(x86\)/Example/1.0/include
If this does not work, you may have to fix the path and add the includes manually in the additional options. For example, replace /C/ with C:/.
-std=c11 -g3 -pedantic -Wall -Wextra -O0 -g -IC:/Program\ Files\ \(x86\)/Example/1.0/include/shared -IC:/Program\ Files\ \(x86\)/Example/1.0/include/other -IC:/Program\ Files\ \(x86\)/Example/1.0/include
If you are using Cygwin make and if you try to clean or rebuild the project with colons in the command, you may get a *** multiple target patterns. Stop. error message. According to the answers from Multiple target patterns? and Very simple application fails with "multiple target patterns" from Eclipse, "make sees the : in the path and thinks it is another target definition, hence the error."
The workaround is to delete the generated build and dist folders every time before you build your project. However, this can be annoying, so you could try MinGW MSYS make instead (not to be confused with MinGW make, which is unsupported).
For MinGW and MSYS configuration instructions, see:
Configuring the NetBeans IDE for C/C++/Fortran:
http://netbeans.org/community/releases/68/cpp-setup-instructions.html#mingw
For working with MinGW and Unicode, you should install the latest version of MinGW-w64. See:
wWinmain, Unicode, and Mingw