I have large C project which I'm compiling manually and then debugging via GDB.
I'm already editing source in Eclipse, but I am not able to compile it there, because of complex and multiple makefile.
Is it possible only to launch app via Eclipse for debugging as via GDB?
Thanks
Yes, you can just set up the debugger to point to the binary and have it launch it. Just make sure you compile it with the right flags (-ggdb and -g3 for symbols). If you have it imported as a Makefile project, it should be able to automatically map your code to the symbols.
Basic instructions are here: http://eclipse.org/jetty/documentation/current/debugging-with-eclipse.html
Related
I made a console C program that reads a .obj 3d model and unflatten it into a multipage PDF. At first I used a little PDF library (https://github.com/AndreRenaud/PDFGen) that worked fine and I was able to compile my code on Windows 11, but I needed to have text rotated and it wasn't possible with PDFGen, so I changed for Cairo Library (https://github.com/freedesktop/cairo). With Cairo my code does exactly what I want, but I didn't find how to compile it on Windows.
I'm using Geany to edit/compile my C code, my build command is :
gcc -Wall -o "%e" "%f" -lcairo -lm
I tried to do the same on Geany on Windows and it didn't work.
I found a repository with standalone cairo DLL for Windows, but didn't manage to use it.
I'm looking for another PDF library that could be used both on Linux and Windows, but for the moment didn't find any.
my code is here (https://github.com/gilboonet/Deplieur-C/blob/main/deplieur.c)
It's my first post here, I'm a long time C programmer but not IT pro and I'm not a Windows user, I only want to compile my code on it because lots of people that will use my program are windows users. Thank you.
I've found a project called "cairo-windows" on Github that creates resources needed to build a C project using Cairo, and it works, even if I needed to use Visual Studio. Sadly, it seems to have problem with pdf creation that only creates a blank file. To make it work I changed the resources (dll and includes) it needs to build the project to those from my gtk windows build it comes with Cairo 1.16.0. If you want to do the same, you must replace the extern directory from cairo-windows (initially fetched by setup-win32.py): lib by cairo.lib, cairo.dll expat.dll fontconfig-1.dll freetype-6.dll and libpng16.dll from your gtk build (..gtk\x64\release\bin) and include by the content of ..\gtk\x64\include.
I am a relatively inexperienced C developer with no previous experience in integrating libraries made by other developers into existing projects.
Basically, I need a means of parsing JSON data in an AVR microcontroller for a university project. To this end I attempted to download and integrate jansson (https://github.com/akheron/jansson) into my existing build of the microcontroller code. I am working with Atmel Studio in Windows 10, but I have also installed Code::Blocks with MinGW GCC (on the same Windows 10 installation) for the purpose of building the library, and to attempt to integrate the library into a native Windows application. So far, neither has been successful, and I get the same errors. All of the online resources I've found so far have been to basic to be useful, or well beyond my comprehension.
This is what I have done thus far:
I began by attempting to build the software and then integrate it into an existing project per the instructions in https://jansson.readthedocs.io/en/2.11/gettingstarted.html. I installed CMake, built the project files for Code::Blocks with cmake.exe -G “CodeBlocks - MinGW Makefiles”, then opened the project and built everything. A few of the targets (I believe related to testing) failed to build, but jansson itself built and output libjansson.a to the \lib\ directory, so I didn’t think too much of it.
That is as far as I’ve been able to get. In both Atmel Studio and Code::Blocks, I do the same thing: add jansson.h to the relevant include paths, add #include “jansson.h” to all of the relevant files, and add libjansson.a as a library in each IDE’s respective linker options. I’ve tried various things like adding and removing flags to the linker, but the output is always “cannot find -ljansson”, “undefined reference to ‘json_object_seed’” (which is a function in the API I’m calling for no reason other than to see if the project has built properly) and/or “ld returned 1 exit status”.
I cannot help but feel as if the issue is with the line “cc -o prog prog.c -ljansson” in the documentation linked above. I really just don’t understand how to set up the linker properly to get the project to build.
If anyone could give some insight into what I’m doing wrong/the correct way to link this library I would appreciate it a lot.
The library itself should be built with appropriate toolchain. I assume that you built your library twice, one version using MinGW toolchain and other with avr-gcc toolchain.
If you compile target application and linker cannot find library, then try to add path of directory that contains *.a file of library to linker settings (linker search path). Let's say you have: /path/to/lib/libjansson.a
In Code::Blocks: Project → Build options → Search directories → Linker add /path/to/lib/. Then it should link with include path set, for example: cc -o prog prog.c -ljansson -L/path/to/lib/
In Atmel Studio when you add a library in Solution Explorer → Libraries → Add Library it should automatically add library search path to linker options. If you check Project → Properties → AVR/GNU Linker there should be (between other options): -Wl,-ljansson -Wl,-L"/path/to/lib/"
If you copied library files (libjansson.a and jansson.h) to your application's project directory, it will be convenient to use relative paths to library files.
I wrote a program containing functions from math.h and clicked on Build All in Eclipse CDT in Ubuntu. No binary was generated. When I built my program from the terminal including the -lm flag, it worked. My guess is that Eclipse CDT did not include the -lm flag when building the source code.
So assuming my guess is correct, why doesn't Eclipse do this by itself? Do I have to change a setting or is there an obstacle that prevents Eclipse from looking at the code and including any necessary libraries in compilation? Or if my assumption is wrong, what might caused Eclipse to not generate a binary?
My question may completely be a noob. Sorry, for that but I have been trying to compile my first Cuda code in Xcode and I'm lost where and how I could set up the IDE to invoke NVCC.
I installed the latest CUDA toolkit CUDA 6.0 and have even installed GCC 4.8 using brew. I have XCODE 5.5
When I run my code from XCODE all the directives like global are marked as unidentified.
I don't where and to change the settings to invoke NVCC. I will be really thankful, if anyone could help me with this.
Further, when I created the XCODE project, I created it as a C project. So, I placed the CUDA code in this C file, which is what is giving me the above mentioned errors. I tried to replace this .C file with a .cu file (just change the extension), which too failed badly - XCODE didn't even know what to do with the .cu files
COuld anyone please help me?
Thanks in Advance
I have given it a try. Although I have not completely succeeded I thought I'd post my progress here in hopes of helping others. The steps I took were inspired by this page.
Create a new Xcode project
Under Build Settings add a new user defined setting CC with the value /usr/local/cuda/bin/nvcc.
Add /usr/local/cuda/include to Header Search Paths under Build Settings.
Set Enable Modules (C and Objective-C) to No.
Add /usr/local/cuda/lib/libcuda.dylib to Link Binary With Libraries under Build Phases.
For any C files you create set their extension to .cu in the File Inspector, after you have done that you have to set the type of that file to C source to get syntax highlighting, by going to Editor->Syntax Coloring->C.
Problems with this setup:
- Xcode can't run the executable, at least nog if it is compiled for debugging. However you can make it copy the executable to some reasonable location and run it in the terminal.
- Whenever you try 'Build for running' sometimes Xcode magically destroys the whole project.
I am asked to debug a C code containing a number of .c files and is complied using a Makefile on a Redhat Linux system. I want to debug that whole code. How to go about it? What changes do i need to make in the Makefile?
I am using gcc as the compiler.
If you're using GCC as compiler add to the CFLAGS variable the -g option. Then you'll be able to debug the resulting executable using the gdb command.
First you need to add the flag "-g" during compilation(make this change in the makefile.if already present then no need). this will open up the symbols for debugging the code.
use the debugging tools available like gdb, dbx, mdb which ever is available in your system.
many resources are available for debugging. one of them is here
Add -g option in your makefile in order to invoke gdb debugger in the future.The way you debug on gdb is like : gdb yourprogram,then you will be redirected to another interface.type "run yourarguments" to start off debugging