How can I set KDevelop to compile codes with gcc properly? - c

I just downloaded KDevelop from Ubuntu Software Center, and have gcc.
I want to see anything happens by pressing F9 but KDevelop says I need to configure a launcher first. And all I know about the setting window is I have to put 'gcc' in somewhere on the window, as well as path to the source code file and path to the executable file it will make.
I have no any knowledge about this window, no any syntax to use in it and can't find it anywhere on the web. Now I desperately require some help. I want to make KDevelop to compile and debug with already-installed gcc and gdb.

It asks you of which executable to debug. You, i suppose, don't want to debug gcc, so you should set this field to your executable. You can also select Project Target option, and choose CMake target that corresponds to your executable.

This step happens after the build step. Make sure your build process is working first (F8).
The window above lets you select which executable in your project should be run when the launch button is pressed.
If your project is created in KDevelop or otherwise uses CMake as the build system, this should be configured by default and use the "target" part of the dialog.
Otherwise the executable should point to the executable you created as part the build process that you want to test.

Related

Equivalent of 'make' command for CodeBlocks?

I am using Codeblocks in Windows 10. Earlier I used to compile only 1 file, so I would just press the 'Build' and 'Run' button on codeblocks.
But, this time there are separate files I need to compile separately (to .o format) and then link to form a single executable file which I need to run. How can I do this in CODEBLOCKS? (In UNIX/LINUX systems, I know this is the 'make' command; but I don't know how to do it here?)
Can anyone help me? I tried reading some help pages on CodeBlocks on the internet, but they were so complicated, I gave up.
make isn't a compiler, and neither is CodeBlocks. make is just a command that runs other commands from a Makefile. The actual command that gets run is something along the lines of gcc a.cpp b.cpp, and it's the same command (or similar enough) that gets run when you build inside CodeBlocks. CodeBlocks should automatically build and link all of the source files that you add to your project. If you aren't seeing this happening, make sure you add them to the project inside of CodeBlocks and don't just put the files in the directory.

C Codelite compile error

I just installed CodeLite onto a brand new PC and I am not able to compile anything. I want to write a console application in C
Simple Executable (gcc)
Compiler: gnu gcc
Debugger: GNU gdb debugger
However, I can't even build a default "hello world" application. All I get is this error:
C:\Windows\system32\cmd.exe /C mingw32-make.exe -j 4 -e -f Makefile
'mingw32-make.exe' is not recognized as an internal or external command,
operable program or batch file.
Now I "googled" this and found out, I have to set up mingw32-make, (which I didn't have to do on 3 other computers) but I can't find a tutorial on how to do that.
Any advice will be highly appreciated!
Thanks in advance.
CodeLite does not install MinGW for you. You need to do it for yourself.
Obviously, CodeLite does not know where to find mingw32-make.exe otherwise, it wouldn't use just mingw32-make.exe instead it uses the full path to mingw32-make, something like C:\TDM-GCC-64\bin\mingw32-make.exe
What you need to do is:
Run CodeLite setup wizard again from Help->Run the Setup Wizard
Follow the steps (5 in total), pay close attention to the Setup Compilers step
If you have installed MinGW before, just click on the Scan button
If you don't have, click the Install button
Open your project settings->General page and select the compiler you just installed in the Compiler field
Make enables the end user to build and install your package without knowing the details of how that is done -- because these details are recorded in the makefile that you supply.
Make figures out automatically which files it needs to update, based on which source files have changed. It also automatically determines the proper order for updating files, in case one non-source file depends on another non-source http://file.As a result, if you change a few source files and then run Make, it does not need to recompile all of your program. It updates only those non-source files that depend directly or indirectly on the source files that you changed.
Make is not limited to any particular language. For each non-source file in the program, the makefile specifies the shell commands to compute it. These shell commands can run a compiler to produce an object file, the linker to produce an executable, ar to update a library, or TeX or Makeinfo to format documentation.

How to find what library was used during a program execution?

I want to know what libraries, external code were actually used during a program's execution. I am working with Inkscape's source code and interested in its command line function that converts svg to png. I want to strip out all its dependencies that's not needed in this execution path.
I am currently using gcov, but so far that only tells me about the Inkscape's code.
My development environment is Windows 2008, mingw gcc package.
Thanks.
Process Explorer will show you all the libraries loaded at runtime, both static and dynamic. It will also show you any handles actively touched during runtime.
You can also spawn and monitor processes from the UI, provided you have your path setup correctly.
Granted, if you have the source code, you can just search for link options during compile time, check the makefiles. For runtime, break point the LoadLibrary method in gdb. In addition, gdb also has an 'info sharedlibrary' command you can use.
If you have ldd under MinGW just use it:
ldd executable or you may use
objdump -p | grep DLL or even
gprof

error compiling C code in Eclipse

I am new to using Eclipse and CDT and have been trying to get my C code to compile. When I Run As Local C Application, it returns an error message Launch Failed. Binary Not Found. I have MinGW-w64 in C:\mingw-w64. The program compiles and runs fine using gcc via cmd.
I would appreciate if eclipse-proficient users can help out with a how-to. Thanks!
Sometimes, if you try to launch first (before binary has been compiled) eclipse creates launch configuration automatically, that has no binary associated. Later even if you compiled your project (you do this using project/build or hammer icon), it will not associate binary automatically, as it tries to launch your old launch configuration. So:
make sure one of projects source files are selected (in editor for example)
click a down arrow next to bug icon
select debug configurations
select C/C++ application and click on "new launch configuration icon"
If C/C++ application field of your new launch configuration is empty, select search project or browse and tell it where your binary is
optionally set other launch/debug options
launch your new launch configuration using "Debug" button or from "bug" menu

Debugging cross-compiled code: Linux->Windows

I'm cross-compiling a project from Linux to target Windows (using mingw). The output is a DLL and p-invoking into it from C# works, but debugging is very difficult. The build outputs a .o file, which can provide symbols to gdb, but basically all I can do there is break on exceptions and find the name of the function that was executing when the exception happened; not even the full stack trace. I can't debug with WinDbg because I don't have .pdb files.
This is an open source project set up to build on Linux; I believe their build process relies on several installed Linux packages to work.
Do I have any options here? Is there a utility that can convert .o files into .pdb? Or some program that can give me more information than gdb when debugging?
Try a IDE that support mingw. For example the open source Code::blocks.
Another possibility is to do it manually: compile it with debug symbols, start you application and attach the GDB debugger to it. It is also part of the MingW32 distribution. Then you can set your breakpoints and debug your application
But I guess using Code::Block is more comfortable
By the way, the GCC compiler does not generate pdb files because it is a propietary format
What xpol means is maybe: if you have a complete mingw installation then Code::blocks can use gdb to visualize a debugging session like it is done in Visual Studio or Eclipse. See chapter "Debugger" at http://www.codeblocks.org/features
You can generate a .pdb file using cv2pdb.exe from Visual D. This works even for programs not written in D if they were compiled with mingw. Once you've downloaded and installed Visual D cv2pdb.exe can be found at C:\Program Files (x86)\VisualD\cv2pdb\cv2pdb.exe.
You can run cv2pdb.exe against an executable like this:
cv2pdb.exe -n target.exe
This will produce a file called target.pdb. Assuming both target.pdb and target.exe are in the current director, you can then use windbg like this:
windbg -sflags 0x80030377 -y . -z target.dmp
In this case I'm also passing a minidump file as target.dmp. This can be omitted. The -sflags 0x80030377 option tells windbg to load target.pdb even though it thinks it doesn't match target.exe.
Note, that it can take windbg a very long time to load target.pdb. Just wait until it no longer says *BUSY* to the left of the command entry box.
Alternatively you can try DrMinGW.

Resources