CodeBlocks : [highlight: No such directory found - c++

I have already read the other questions on the site and none of them matched with the issue I had.
I have already tried unistalling and then reinstalling codeblocks.
Please help.
Build Log :
mingw32-g++.exe -Wall -fexceptions -g -c S:\Coding\C++\aloo\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\aloo.exe obj\Debug\main.o
[highlight color=”yellow”]-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32[/highlight] "C:\Program Files (x86)\CodeBlocks\MinGW\lib\libbgi.a"
mingw32-g++.exe: error: [highlight: No such file or directory
mingw32-g++.exe: error: color=”yellow”]-lbgi: No such file or directory
mingw32-g++.exe: error: C:\Program Files (x86)\CodeBlocks\MinGW\lib\libbgi.a: No such file or directory
Process terminated with status 1 (0 minute(s), 4 second(s))
3 error(s), 0 warning(s) (0 minute(s), 4 second(s))

I have successfully solved the problem.
All I did was go to "Compiler Settings" ("Settings" -> "Compiler" -> Global compiler settings), and selected "Reset Defaults".
It solved the problem.
Thanks everyone for answering. :)

Start by turning on full Compiler logging.
This is done by selecting the "Full command line" option Under menu "Settings" -> "Compiler" -> Global compiler settings -> [the compiler you use] -> "Other Setting" tab, "Compiler logging". In 12.11 and newer this is enabled by default.
This option will make Code::Blocks output the exact commands it uses to compile your code.
Things to remember:
Look at the "Build Log" NOT the "Build Message" tab
Do a re-build instead of build in order to get a full build log.
You should review all the commands and their options;
If you have compiled your app before, do a re-build (or clean before build) to see all compiling / linking steps;
If you don't know what an option or a command does please read the documentation for the compiler/linker you're using;
Look for missing commands;
For every source file (.cpp; .c; .d; etc) in your project, you must have at least one command in the log. This command must produce an object file (file extension .o if using gcc/g++ and .obj if using Visual Studio);
Every object file should be linked in the final executable, if not there are undefined symbols errors;
Remember the file extension matters: *.c is compiled as C file, *.cpp is compiled as C++ file.
If you have no luck, you can try to ask in the forum, but read first "How do I report a compilation problem on the forums"
From Code::Blocks FAQ

Related

C++ CodeBlocks and wxWidgets file not found?

I'm pretty new to C::B and just installed it along with building wxWidgets. I'm pretty sure my wxWidgets build with MinGW is good, i was able to successfully create a wxWidgets project in C::B using the "minimal.cpp" sample in wxWidgets. However now instead of creating an empty project, I'm using leaving "Empty project" unchecked in wizard to create the program. With wxWidgets this creates 2 source files and 2 header files (for app and main). When I try to build+play the project though without making any changes i get this error:
-------------- Build: Debug in MULLSIMPLE (compiler: GNU GCC Compiler)---------------
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -I"C:\Program Files\wxWidgets-3.0.5\include" -I"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll\mswud" -c "C:\Users\gmloo\OneDrive\Desktop\C++ Projects\MULLSIMPLE\wx_pch.h" -o wx_pch.h.gch\Debug_wx_pch_h_gch
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -I"C:\Program Files\wxWidgets-3.0.5\include" -I"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll\mswud" -c "C:\Users\gmloo\OneDrive\Desktop\C++ Projects\MULLSIMPLE\MULLSIMPLEApp.cpp" -o obj\Debug\MULLSIMPLEApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -I"C:\Program Files\wxWidgets-3.0.5\include" -I"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll\mswud" -c "C:\Users\gmloo\OneDrive\Desktop\C++ Projects\MULLSIMPLE\MULLSIMPLEMain.cpp" -o obj\Debug\MULLSIMPLEMain.o
windres.exe -I"C:\Program Files\wxWidgets-3.0.5\include" -I"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll\mswud" -J rc -O coff -i C:\Users\gmloo\OneDrive\Desktop\C__PRO~1\MULLSI~1\resource.rc -o obj\Debug\resource.res
g++.exe -L"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll" -o bin\Debug\MULLSIMPLE.exe obj\Debug\MULLSIMPLEApp.o obj\Debug\MULLSIMPLEMain.o obj\Debug\resource.res -mthreads -lwxmsw30ud_core -lwxbase30ud -lwxpngd -lwxzlibd -mwindows
gcc: error: Files\wxWidgets-3.0.5\include: No such file or directory
gcc: error: Files\wxWidgets-3.0.5\lib\gcc_dll\mswud: No such file or directory
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minute(s), 14 second(s))
Process terminated with status 0 (0 minute(s), 16 second(s))
3 error(s), 0 warning(s) (0 minute(s), 16 second(s))
Saying that it can't find files? the wxWidgets-3.0.5 is actually in c:\Program Files/wxWidgets-3.0.5, so maybe its looking in the wrong place? Or maybe I missed a step setting it up?
This is absolutely everything I did to install C::B, install wxWidgets, and create my project
1. Installing CodeBlocks
a. Clicked codeblocks-20.03mingw-setup.exe from website, then download started automaticallty from fosshub
b. Ran executable to install and for type of install did "All plugins, all tools, just everything"
-all checkboxes were checked, including
1. Default Install
2. Contrib Plugins
3. C::B CBP2Make
4. C::B Share Config
5. C::B Launcher
6. MinGW Compiler Suite
2. Downloading wxWidgets
a. Clicked "Windows ZIP" from downloads page on website under "Latest Stable Release: 3.0.5"
b. Extracted download to c:\Program Files\wxWidgets-3.0.5
-first file asked for administrator permission, i said "dont ask again" and clicked "continue"
3. Added MinGW to path
a. went into c:\Program Files\CodeBlocks\MinGW\bin and copied that path to PATH environment variables
4. Building wxWidgets
a. opened a terminal with admin privileges and went to c:\Program Files\wxWidgets-3.0.5\build\msw.
b. entered commands as suggested at https://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW, except changed
BUILD=release to BUILD=debug:
1. mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug clean
2. mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug
c. wxWidgets successfully built (3:38 pm to 4:22pm!)
5. Opened CodeBlocks
a. got message that "After auto-detection, at least one compiler's master path is still empty and therefore invalid.
Inspect the list below and change the compiler's master path later in the compiler options. Select you favourite
default compiler here:"
-There's one compiler listed as detected: GNU GCC Compiler
-With this compiler highlighted, i clicked "Set as default" and then ok.
b. got message CodeBlocks is not default app for C/C++ source files.
-Selected "Yes, associate with C/C++ files"
7. Testing Compiler
-I wasn't sure what to do about "setting compiler master path..." msg earlier, so I just created a new project with type
"Console application", compiled the basic "Hello world" application, ran it, ran fine, so I assume compiler is working?
6. Create new wxWidgets program:
a. Create new project: wxWidgets project
b. Wizard Steps:
PAGE 1:
-Set version: wxWidgets 3.0.x
PAGE 2:
-Named project "MULLSIMPLE" and created directory
PAGE 3:
-Skipped Author info.
PAGE 4:
-Preferred GUI Builder: None
-Application Type: Frame Based
PAGE 5:
-wxWidgets location: C:\Program Files\wxWidgets-3.0.5
-When I hit next, it opens the global variable editor. I don't know how to use this,
so i just hit ok without making any changes. IT asked if i want to save an invalid global var,
i said yes. Now the widgets location in the wizard is a path instead of a global variable,
I assume this is ok for now
PAGE 6:
-By default "Debug" configuration checked, "Release" configuration is unchecked
-make no changes
PAGE 7:
-Under wxWidgets library settings:
-CHECK Use wxWidgets DLL
-UNCHECK wxWidgets built as monolithic
-CHECK enable unicode
-Under Miscellaneous settings:
-UNCHECK create empty project
-CHECK create and use PCH
-Leave configuration input field blank
-UNCHECK Configure Advanced Options
-On next get dialog re PCH default settings, click YES to accept
PAGE 8:
-Didn't select any additional libs to add to project,
just hit finish
8. Try Build and run
-Get the build log error at start of post re: missing files
Thanks
#user4581301 thanks for your response it looks like that was the problem. I copied the wxWidgets-3.0.5 to the desktop. Then i opened up the old one in prog files, cleaned the build, then deleted that folder. Then i created a new C::B proj using the wxWidgets path to the one on the desktop, and now the error is gone.
I don't 100% understand how wxWidgets works so I hope just copying the whole folder to another location is fine, but so far program seems to be working. Thanks

MinGW's ar.exe "could not create temporary file whilst writing archive: no more archived files" error upon building in Codeblocks

So I am trying to build Odamex in Codeblocks and running into a problem that I have not found any solution to. I am erroring out in the first build sequence with this specific error:
ar.exe: could not create temporary file whilst writing archive: no more archived files
full readout:
cmd /c if exist ..\..\lib\libtextscreen.a del ..\..\lib\libtextscreen.a
ar.exe -r -s ..\..\lib\libtextscreen.a ..\..\obj\libtextscreen\gcc\release\txt_button.o ..\..\obj\libtextscreen\gcc\release\txt_checkbox.o ..\..\obj\libtextscreen\gcc\release\txt_desktop.o ..\..\obj\libtextscreen\gcc\release\txt_dropdown.o ..\..\obj\libtextscreen\gcc\release\txt_fileselect.o ..\..\obj\libtextscreen\gcc\release\txt_gui.o ..\..\obj\libtextscreen\gcc\release\txt_inputbox.o ..\..\obj\libtextscreen\gcc\release\txt_io.o ..\..\obj\libtextscreen\gcc\release\txt_label.o ..\..\obj\libtextscreen\gcc\release\txt_radiobutton.o ..\..\obj\libtextscreen\gcc\release\txt_scrollpane.o ..\..\obj\libtextscreen\gcc\release\txt_sdl.o ..\..\obj\libtextscreen\gcc\release\txt_separator.o ..\..\obj\libtextscreen\gcc\release\txt_spinctrl.o ..\..\obj\libtextscreen\gcc\release\txt_strut.o ..\..\obj\libtextscreen\gcc\release\txt_table.o ..\..\obj\libtextscreen\gcc\release\txt_utf8.o ..\..\obj\libtextscreen\gcc\release\txt_widget.o ..\..\obj\libtextscreen\gcc\release\txt_window.o ..\..\obj\libtextscreen\gcc\release\txt_window_action.o
ar.exe: creating ..\..\lib\libtextscreen.a
ar.exe: could not create temporary file whilst writing archive: no more archived files
Process terminated with status 1 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))
From googling it seems it may be related to folder permissions, but I have full permissions on all folders.
Has anyone else ran into this error when building a project on Codeblocks?? Cant find any other threads. Any hints would be great thank you!
I have encountered a similar problem trying to build a static lib via Eclipse and I am confused too.
using toolchain "MinGW GCC" with CDT internal builder:
19:37:16 **** Rebuild of configuration Debug for project myLibS ****
Info: Internal Builder is used for build
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o q1.o "..\\q1.c"
ar -r libmyLibS.a q1.o
ar: creating libmyLibS.a
ar: could not create temporary file whilst writing archive: no more archived files
19:37:17 Build Finished. 0 errors, 0 warnings. (took 906ms)
So far I have only found a workaraoound
using toolchain "cygwin GCC" with CDT internal builder:
19:14:37 **** Rebuild of configuration Debug for project myLibS ****
Info: Internal Builder is used for build
gcc -O0 -g3 -Wall -c -fmessage-length=0 -o q1.o "..\\q1.c"
ar -r libmyLibS.a q1.o
/usr/bin/ar: creating libmyLibS.a
19:14:37 Build Finished. 0 errors, 0 warnings. (took 937ms)
I hope somebody has a solution to that MinGW problem.
I had the same problem but only when I added or modified Environment settings under the C/C++ Build project options.
I have found that, if I select (underneath the environment variables) "Append variables to native environment" the error goes away.

how do I eliminate linker error mingw32/bin/ld.exe: cannot find -lSDL

I am trying to build SDL for use with Eclipse. I am trying to remove this linker error:
Beginning Compilation
21:15:53 **** Incremental Build of configuration Debug for project CMD ****
Info: Internal Builder is used for build
g++ "-IC:\\MinGW\\include\\SDL2" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\CMD.o" "..\\src\\CMD.cpp"
g++ -o CMD.exe "src\\CMD.o" -lmingw32 -lSDL -lSDL2main -lSDL2
ERROR(s):
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL
collect2.exe: error: ld returned 1 exit status
21:15:54 Build Finished (took 1s.36ms)
The most pertinent SO archive source I researched didn't seem to have an actionable answer for my problem, though it had the exact same problem/error:
title --
producing the same error message:
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL.
If you click to the authors "solution" for the same error as mine its not clear to me how he solved it.
Any help?
Problem solved, SDL2 awesome. Ok:
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -lSDL.
Reinstallation of SDL2 avoiding binary conflict between SDL files and SDL2 files
as keltar mentioned resolved the immediate problem, and the problem built with no errors!Fixing what was in the braces unmasked new problem: crashing. I stripped the program to bare bones and concluded the crashing was outside of the code since it was occurring even without code.
To solve the new problem would need to go the SDL2 distribution file (the one copied to MinGW) and copy the SDL2.dll from it [DLL from distributable][1]--- by dragging the file over your debug and/or release folders where the .exe file lives.(.exe + dll -> right?) moving dll to exes. Build/Run the program
it should work!
You should see a Welcome message!
https://www.caveofprogramming.com/c-for-complete-beginners/setting-up-sdl-windows.html

Static-linking of SDL2 libraries

I am using Windows 7, Code::Blocks and MinGW. I have little to no experience when it comes to compiling/building anything, especially when Code::Blocks doesn't use makefiles.
I downloaded SDL2-devel-2.0.0-mingw.tar.gz (SDL Development Libraries) from http://www.libsdl.org/tmp/download-2.0.php, and I'd like to create a standalone executable using SDL2 libraries, but so far I've always had to bundle the SDL2.dll file with the executable to make it work.
I've heard that I can not static-link dynamic libraries, so my only option seems to be doing something with the source files using the file SDL2-2.0.0.tar.gz (Source Code) from the link I mentioned above. However, I do not know what I should do with those.
What I managed to try with the source files is importing the Visual Studio project to Code::Blocks and building it, but it tells me "sdl-config No such file or directory" (I do not know what triggered that). I'm also not sure if building merely gives me an executable, with which I do not know what I can do to link it to my own executable.
A fool proof idiot's step by step guide would be the best bet to solve this case.
EDIT:
I managed to compile the SDL libraries with the guide Jonas provided, and got a libSDL2.a file.
At first I only added the path of libSDL2.a to "Link libraries:" -section of Code::Blocks, but I got a bunch of errors such as "SDL_Init() not declared in this scope".
In addition to the libSDL2.a path, I also added the path of SDL2-2.0.0\include to the Compiler's search directory as well as the path of SDL2-2.0.0\build.libs to the Linker's search directory. I also wrote this to my test file: #include "SDL.h". My test file now looks like this:
#include "SDL.h"
int main( int argc, char* args[] ) {
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
//Quit SDL
SDL_Quit();
return 0;
}
It appears it did fix the declaration problem, but now Code::Blocks opened a SDL_mmjoystick.c file and gave me even more errors: "undefined reference to 'waveInClose#4'", "undefined reference to 'waveOutClose#4'", "undefined reference to 'joyGetNumDevs#0'" and tons of other ones.
Here's a screenshot of what's happening, note the different color of #include texts, I'm not sure why that happens: http://gyazo.com/00656a9c1e57a2bd0db1414fa7d68ced.png
I am not sure how to correctly take this library into use. Any help in this case, or should I make another question for it?
EDIT:
I added -lSDL2 to the linker options and deleted the other parameters. Now it builds fine:
mingw32-g++.exe -Wall -fexceptions -g -IC:\Users\User\Desktop\SDL2-2.0.0\include -c "C:\Users\User\Desktop\CppProjects\SDL project\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -Wall -fexceptions -g -IC:\Users\User\Desktop\SDL2-2.0.0\include -c "C:\Users\User\Desktop\CppProjects\SDL project\thetestfile.cpp" -o obj\Debug\thetestfile.o
mingw32-g++.exe -LC:\Users\User\Desktop\SDL2-2.0.0\build\.libs -o "bin\Debug\SDL project.exe" obj\Debug\main.o obj\Debug\thetestfile.o -lSDL2 ..\..\SDL2-2.0.0\build\.libs\libSDL2.a C:\Users\User\Desktop\SDL2-2.0.0\build\.libs\libSDL2.a -mwindows
Output size is 945.80 KB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings (0 minutes, 1 seconds)
But when I try to run it, it says my computer lacks SDL2.dll, while the whole point was to static-link.
So currently I have the path to build/.libs in my Link libraries -settings, -lSDL2 in the Other linker options, and for search directories I have the path to SDL2-2.0.0/include for the compiler and SDL2-2.0.0/build/.libs for the linker.
In the build/.libs directory I can also see libSDL2.a, libSDL2.dll.a, libSDL2.la and libSDL2.lai files, which I don't know what they are.
It's not necessary to recompile the library,
SDL2 is given with static-link library named "libSDL2.a"
on the folder "SDL2-2.0.0\i686-w64-mingw32\lib\".
Just be sure to add these options to the linker :
"-lmingw32 -lSDL2main -lSDL2 -mwindows -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -static-libgcc"
on Code:Blocks at "Project / Build Options... / Linket settings / Other linker options"
These options allow you to link with what SDL2.dll was using.
You can retreive them on the file "SDL2-2.0.0\i686-w64-mingw32\bin\sdl2-config"
The magical trick is to delete or rename the file "libSDL2.dll.a"
on the folder "SDL2-2.0.0\i686-w64-mingw32\lib\".
I added a "-" before to keep it in case I need it.
I don't know why this librairy overcomes the other and a clue would be appreciated.
I tried with Code::Blocks 12.11 MinGW32 and it worked.
If you run with some projects that use dynamic-link
and some other which use static-link, you will have to
keep your librairies in two different folders knowing that
"libSDL2main.a" will be in those two.
Sorry for my writing, I'm not used to write in english.
Mike

QT5 attaching project name with every sourcefile name, compiling error

i want to get started with QT. I donwloaded QT5 MINGW compiler with QT creator and i am trying to build the pre attached example named affine the problem is that the QT5 i think embed the project name with each of source file and thus gives error that file not found. some thing similar
:-1: error: ..affinemain.cpp: No such file or directory
while the file name is just
main.cpp
i don't know how to fix it. I searched lot on internet but could not found anything useful.
I even try to compile from command prompt but i am not fimmiliar with command prompt compiling as i am new to QT and previously i am totally developed with IDE in visual studio and eclipse for java so i have no idea about the make file and compiler command line arguments.
could some body please help me to fix this issue and can you tell please why compiler attaching project name with the source file name?
Thanks in advance
I have got the same problem and my solution may help you.
I am working with Qt5.0.1 now, and there are two distributions to work on windows with it: Qt5.0.1-mingw and Qt5.0.1-msvc2010.
I had to use mingw and there was a problem on my setup that "/" is ignored in path's.
So according to Qt Creator, compiler was called to process file mainwindow.cpp and this file was passed to it
g++ /*truncated*/ ..\qt-example\mainwindow.cpp
Below is the full compiler input:
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN -I..\qt-example -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtGui" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtCore" -I"debug" -I"." -I"." -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\mkspecs\win32-g++" -o debug\mainwindow.o ..\qt-example\mainwindow.cpp
And the error produced.
g++.exe: error: ..qt-examplemainwindow.cpp: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.
So, we can see that "\" is ignored by the compiler and file name is merged with directory name.
The solution to that problem goes to the tools that are used - MinGW (Minimalist ports of GCC and Binutils). And also MSYS - a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. In our case - g++.
MSYS is not shipped with Qt5.0.1-mingw and g++ is not using it, but having MSYS available in your PATH environment variable breaks the system.
MSYS is used for git scm, which I have installed, so my path contains links to MSYS that goes bundled with git. So I have next paths in my PATH environment variable.
C:\Program Files (x86)\git\bin;C:\Program Files (x86)\git\cmd
I have not found how MSYS is used by Qt Creator or g++, or where it is linked, but when I have dropped next path from PATH:
C:\Program Files (x86)\git\bin;
and restarted Qt Creator - g++ succeeded on compiling my file, it worked.
The question why/how it influences the Qt Creator/g++ that should not use MSYS utils installed with git is still open.
i can´t comment.
important : delete all the files in the release and debug folder (compiled version) before try the tips of the autor ...