I want to debug a code with codeblocks. It is not possible if I use the SDL2 lib.
The building of the bin/debug/*.exe is ok...but when I run it there is the following message:
Starting debugger: gdb.exe -nx -fullname -quiet -args .../bin/Debug/dsl2_test4.exe
done
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 8.1
Error creating process ...\bin\Debug\dsl2_test4.exe, (error 193).
Debugger finished with status 0
It appears when I add #include <SDL.h>
Has someone an idea to solve my problem because I would like to debug complex code using SDL2...
example of code:
#include <exception>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <SDL.h>
int main(int argc, char* argv[])
{
int a;
int b = 5;
a = b+6;
return 0;
}
I want to run a debug *.exe with "#include <SDL.h>"
edit 1
build log is :
-------------- Clean: Debug in dsl2_test4 (compiler: GNU GCC Compiler)---------------
Cleaned "dsl2_test4 - Debug"
-------------- Build: Debug in dsl2_test4 (compiler: GNU GCC Compiler)---------------
g++.exe -Wall -g -I..\SDL2\SDL2-devel-2.24.0-mingw\SDL2-2.24.0\x86_64-w64-mingw32\include\SDL2 -c ...\dsl2_test4\main.cpp -o obj\Debug\main.o
g++.exe -LC:\SDL2\SDL2-devel-2.24.0-mingw\SDL2-2.24.0\x86_64-w64-mingw32\lib -o bin\Debug\dsl2_test4.exe obj\Debug\main.o -lmingw32 -lSDL2main -lSDL2.dll -luser32 -lgdi32 -lwinmm -ldxguid
\dsl2_test4\main.cpp: In function 'int SDL_main(int, char**)':
\dsl2_test4\main.cpp:11:9: warning: variable 'a' set but not used [-Wunused-but-set-variable]
int a;
^
Output file is bin\Debug\dsl2_test4.exe with size 85.52 KB
Running project post-build steps
XCOPY ...\SDL2\SDL2-devel-2.24.0-mingw\SDL2-2.24.0\x86_64-w64-mingw32\bin\*.dll bin\Debug\ /D /Y
0 fichier(s) copi‚(s)
Process terminated with status 0 (0 minute(s), 1 second(s))
0 error(s), 1 warning(s) (0 minute(s), 1 second(s))
(I have manually copied SDL2.dll in bin/debug)
Compiler and Debugger settings are
Debugger settings -> GDB/CDB debugger -> Default : excutable path : C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe
Compiler settings ->Debugger : GDB/CDB debugger : Default
looking at other forums, the problem is solved : I add "#undef main" after "#include <SDL.h>"
Related
As the title says I'm having a difficult time compiling the Hello, World! example from sciter.com. As far as I can tell I have everything linked properly, I made sure that the bit architecture of my DLL's matched that of my project, etc.
I have been trying to figure it out for hours now and sciters website has no previously asked questions on the topic. Was hoping someone could point me in the right direction.
Here's the compiler output:
====================[ Build | SciterDemo | Debug ]==============================
"C:\Program Files\JetBrains\CLion 2022.2.1\bin\cmake\win\bin\cmake.exe" --build C:\Users\edwar\CLionProjects\SciterDemo\cmake-build-debug --target SciterDemo -j 12
[0/1] Re-running CMake...
-- Configuring done
-- Linking Sciter
-- Generating done
-- Build files have been written to: C:/Users/edwar/CLionProjects/SciterDemo/cmake-build-debug
[1/1] Linking CXX executable SciterDemo.exe
FAILED: SciterDemo.exe
cmd.exe /C "cd . && C:\PROGRA~1\JETBRA~1\CLION2~1.1\bin\mingw\bin\G__~1.EXE -g CMakeFiles/SciterDemo.dir/main.cpp.obj -o SciterDemo.exe -Wl,--out-implib,libSciterDemo.dll.a -Wl,--major-image-version,0,--minor-image-version,0 sciter-js-sdk-main/bin/windows/x64/libsciter.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:\Program Files\JetBrains\CLion 2022.2.1\bin\mingw\bin/ld.exe: C:/PROGRA~1/JETBRA~1/CLION2~1.1/bin/mingw/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text+0x46): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
EDIT:
Here is the code in my main.cpp file:
#include "sciter-js-sdk-main/include/sciter-x.h"
#include "sciter-js-sdk-main/include/sciter-x-window.hpp"
#include "include/sciter-win-main.cpp"
class frame: public sciter::window {
public:
frame() : window(SW_TITLEBAR | SW_RESIZEABLE | SW_CONTROLS | SW_MAIN | SW_ENABLE_DEBUG) {}
SOM_PASSPORT_BEGIN(frame)
SOM_FUNCS(
SOM_FUNC(nativeMessage)
)
SOM_PASSPORT_END
sciter::string nativeMessage() {return WSTR("Hello, World!");}
};
#include "resources.cpp"
int uimain(std::function<int()> run ) {
sciter::archive::instance().open(aux::elements_of(resources));
sciter::om::hasset<frame> pwin = new frame();
pwin->load((WSTR("this://app/main.htm")));
pwin->expand();
return run();
}
As you can see it only has uimain which per the Hello World! tutorial is correct. I don't know if maybe this is causing an issue.
Summarizing the problem as generally as possible:
I used to compile the program via terminal with the sequence of commands even in bash.
Basically:
g++ test.cpp -o teste.exe
chmod +x teste.exe
./teste.exe
At the terminal it works perfectly. But Codeblock practically does not create the program's executable.
Simple example program created:
#include <iostream>
int main(){
std::cout << "Test\n";
return 0;
}
I press "Build and run" (At first it detects g++ so I selected the only one I had.).
Nothing, just this:
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------
g++ -c "/home/williambronzo/Área de Trabalho/teste.cpp" -o "/home/williambronzo/Área de Trabalho/teste.o"
g++ -o "/home/williambronzo/Área de Trabalho/teste" "/home/williambronzo/Área de Trabalho/teste.o"
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Checking for existence: /home/williambronzo/Área de Trabalho/teste
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------
g++ -c "/home/williambronzo/Área de Trabalho/teste.cpp" -o "/home/williambronzo/Área de Trabalho/teste.o"
g++ -o "/home/williambronzo/Área de Trabalho/teste" "/home/williambronzo/Área de Trabalho/teste.o"
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
There is some detail that I missed to be able to use the codeblock, otherwise I will be in the terminal and bash. I heard that new students are afraid of the terminal. So I'm trying to use something that should be "easy" (the terminal is easy for me but not for others).
Detail:
Use linux minimal ubuntu version with essential installation.
Have you checked that the compiler is configured correctly? A similar problem happened to me.
To resolve, go to Settings >> Global Compiler Settings >> Toolchain executables and click on "Auto-Detect".
After that the problem must be solved, if not, make sure that the mingw has been installed correctly.
Everything correct except the folder with space, after changing the directory to test the program it worked without problems, with my research I found that this bug exists since 2007 after 13 years, I was surprised to come across this problem not fixed.
Link:
http://forums.codeblocks.org/index.php/topic,5003.0.html
No problems:
g++ "/home/williambronzo/Área de Trabalho/teste.cpp" -o "/home/williambronzo/Área de Trabalho/teste.exe"
Same problem:
g++ /home/williambronzo/Área de Trabalho/teste.cpp -o /home/williambronzo/Área de Trabalho/teste.exe
Out put erro:
g++: error: /home/williambronzo/Área: Arquivo ou diretório inexistente
g++: error: de: Arquivo ou diretório inexistente
g++: error: Trabalho/teste.cpp: Arquivo ou diretório inexistente
g++: error: de: Arquivo ou diretório inexistente
g++: error: Trabalho/teste.exe: Arquivo ou diretório inexistente
g++: fatal error: no input files
compilation terminated.
The incredible thing that puts double quotes in the code output (build log), but apparently runs the program underneath without double quotes.
If it weren't for the sam varshavchik tip, I wouldn't have found the problem. After all, I was wondering where the program was putting the, "teste.o" and "teste". Then I looked at the folder spaces. (Noobs error.)
My solution:
Avoid folders with spaces.
Change the:
"/home/williambronzo/Área de Trabalho/teste.cpp"
For:
"/home/williambronzo/Documentos/[Filename without space]/teste.cpp"
Probably if your main language or the selected computer language does not include spaces in the directories you will not find an error, but if there is space in any directory you will find this Codeblocks error.
I'm sorry for bothering you with a trivial error and Thank you all.
I’m new to C++, only experienced in Java so far, so please be precise with the answers.
I translate the error from German to English, so they might not match the English counterpart.
I was trying to set up the IDE Codeblocks on Ubuntu, and tried to test it with a simple Hello World program.
Trying to "Build and run" the program caused two errors in the build log:
"-------------- Build: Debug in TestProject (compiler: GNU GCC Compiler)---
g++ -Wall -std=c++11 -g -c /home/marcel/Dokumente/Dokumente/Privat/Udemy/C++/Übung/TestProject/src/Main.cpp -o obj/Debug/src/Main.o
g++ -o bin/Debug/TestProject obj/Debug/src/Main.o
g++: error: obj/Debug/src/Main.o: File or directory not found
g++: fatal error: no input files
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))"
I tried to look it up, but most people seemed to have more problems than just these two files. None of their Solutions worked.
So far I've wasted a few days trying to fix it, so I thought I would ask here.
I downloaded the source of a small openGL project but when i try to compile it gives me this error message ("error: ld returned 1 exit status") and i dont know how to fix it. Does anyone know what it means?
The program uses openGL with GLFW 2.
Here's the build log:
-------------- Build: Debug in Procedurus (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -L"C:\Program Files (x86)\CodeBlocks\MinGW\lib" -L"C:\Program Files (x86)\CodeBlocks\MinGW\lib" -o bin\Debug\Procedurus.exe obj\Debug\Application\TextTool.o obj\Debug\Geometry\AstronomicalObject.o obj\Debug\Geometry\Atmosphere.o obj\Debug\Geometry\CloudLayer.o obj\Debug\Geometry\Frustum.o obj\Debug\Geometry\Geometry.o obj\Debug\Geometry\Particle2D.o obj\Debug\Geometry\Planet.o obj\Debug\Geometry\PlanetRing.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrain.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrainFace.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrainNode.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrainPatch.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrainPatchTopology.o obj\Debug\Geometry\QuadtreeTerrain\RidgedMultifractalSphericalQuadtreeTerrain.o obj\Debug\Geometry\QuadtreeTerrain\SphericalQuadtreeTerrain.o obj\Debug\Geometry\SimpleCircle.o obj\Debug\Geometry\SimpleCylinder.o obj\Debug\Geometry\SimpleDisk.o obj\Debug\Geometry\SimpleSphere.o obj\Debug\Geometry\Skybox.o obj\Debug\Geometry\Star.o obj\Debug\Geometry\Starfield.o obj\Debug\GL\GLee.o obj\Debug\Math\Randomizer.o obj\Debug\ProcedurusMain.o obj\Debug\Shaders\ShaderManager.o -lopengl32 -lglfw -lglu32 -lgdi32 -lGLFW GL/glfw
GL/glfw: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
So the problem is with the file named "glfw" but if i delete it and keep only the glfw.h it gives me another error ("mingw32-g++.exe: error: GL/glfw: No such file or directory
")
I can upload the project if that helps.
You have an extra GL/glfw in your compile command, you should delete this, it is not necessary.
After googling for InterlockedCompareExchange errors, it seems like it always points to an old error for mingw64, and I am using mingw32.
It seems to happen to all examples that use threads, but if I just have "#include <boost/thread.hpp>" and no calls of a thread it will work, so I think I did the linking correct.
This is my build:
-------------- Build: Debug in UDP_EXAMPLE (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -D_WIN32_WINNT=0x0501 -g -IC:\boost_1_56_0 -c "C:\Users\poteto\Desktop\Other Programming\UDP_EXAMPLE\server.cpp" -o obj\server.o
In file included from C:\boost_1_56_0/boost/thread/win32/thread_data.hpp:11:0,
from C:\boost_1_56_0/boost/thread/thread_only.hpp:15,
from C:\boost_1_56_0/boost/thread/thread.hpp:12,
from C:\boost_1_56_0/boost/thread.hpp:13,
from C:\Users\poteto\Desktop\Other Programming\UDP_EXAMPLE\server.cpp:5:
C:\boost_1_56_0/boost/thread/win32/thread_primitives.hpp:180:0: warning: ignoring #pragma intrinsic [-Wunknown-pragmas]
mingw32-g++.exe -o Debug\http_server.exe obj\server.o -lws2_32 -lwsock32 C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a C:\boost_1_56_0\stage\lib\libboost_system-mgw47-mt-1_56.a
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x1e): undefined reference to `_InterlockedCompareExchange'
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x70): undefined reference to `_InterlockedCompareExchange'
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0xb5): undefined reference to `_InterlockedCompareExchange'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 11 second(s))
3 error(s), 1 warning(s) (0 minute(s), 11 second(s))
I linked the libraries: libboost_thread and libboost_system. I am using Codeblocks. Other asio examples without threads work.
In the example:http://www.ce.unipr.it/~medici/udpserver2.html
If I were to remove the call to the thread, it would work.