gcc find installed libraries - c

Is there a way to list all the installed libraries and/or query if a specific library is installed with gcc? I want to know if glut is available on my system (without browsing all the library path).
I am using mingw w/ gcc 4.5.2 under windows.

The way to check will generally be platform and compiler dependent. Getting it 100% right is hard.
You can use a build system like CMake for generating your actual build system (confused yet ;-)?)
I found a small tutorial which explains how to find glut for you. Essentially, all you need is
find_package(GLUT)
in your CMakeLists.txt. To get to know cmake, I suggest you read/follow their tutorial

I believe your best bet is to try to compile and link a simple example.
Gcc will complain about any libraries it can't find.
You may also try to use a smart IDE (CDT) and try to auto-complete your #include statement. That may as well list all your installed libs.

Related

undefined reference to 'sqrt' but only when using variables AND only in CodeBlocks [duplicate]

C++ GUI Tutorial: undefined reference to TextOut
I have the same problem, but I'm new to programming and Code::Blocks, and I want to use the GDI32 library. How can I install it? I'm very confused because I can use the windows.h header, but some functions like TextOut aren't available.
The gdi32 library is already installed on your computer, few programs will run without it. Your compiler will (if installed properly) normally come with an import library, which is what the linker uses to make a binding between your program and the file in the system. (In the unlikely case that your compiler does not come with import libraries for the system libs, you will need to download the Microsoft Windows Platform SDK.)
To link with gdi32:
This will reliably work with MinGW-gcc for all system libraries (it should work if you use any other compiler too, but I can't talk about things I've not tried). You can also write the library's full name, but writing libgdi32.a has no advantage over gdi32 other than being more type work.
If it does not work for some reason, you may have to provide a different name (for example the library is named gdi32.lib for MSVC).
For libraries in some odd locations or project subfolders, you will need to provide a proper pathname (click on the "..." button for a file select dialog).
You can create new with project win32 gui api it has default add library -lgdi32 -luser32 -lkernel32 -lcomctl32 -mwindows or add library -mwindows in your project, it worked for me.
At a guess, you used Code::Blocks to create a Console Application project. Such a project does not link in the GDI stuff, because console applications are generally not intended to do graphics, and TextOut is a graphics function. If you want to use the features of the GDI, you should create a Win32 Gui Project, which will be set up to link in the GDI for you.

Using different GCC to build Linux vs Linux Apps

This question may seem weird for some gurus out there, but I'm a little perplexed.
Basically what I want to do is to evaluate different tool chain for developing applications on embedded Linux. Say I have my Linux built using Yocto Project, which cross-compiles GCC from scratch can provide it as a cross toolchain for apps developers.
But if I want to try out different toolchains fro this point, say Sourcery CodeBench or a toolchain generated using BuildRoot, is it possible to build a applications using these toolchains and still run them on the Yocto-generated Linux? I'd imagine this is doable is built statically. But if we then want to link dynamically, it's simply a matter of copying over libc?
Thanks for the help. Sorry if question is ambiguous.

Compiling a file with TCC on windows with a library from C99

So the latest version of TCC supposedly has some of the features of C99 implemented, however, I have found that it does not include C99's Math library.
Is there a way I can get it to use more of C99's libraries on windows? I googled around and found some advice mostly pertaining to Linux, but for this project I need to get it to work on windows.
EDIT: This is not a question about getting 'any' compiler on the windows platform. I realize that there are many compilers. I specifically need to get TCC to do this.
EDIT: The project needs to do some on the fly C compilation, and we would like to see if we can use TCC for this feature.
The documentation for Windows indicates that the TCC installation on Windows deploys a minimal set of MinGW headers. Copy the headers you need from MinGW into the tcc/include/winapi (i.e. place them under tcc-build-root/win32/include/winapi) and then build tcc with build-tcc.bat.
Try Visual Studio Express Edition for 'C'.It's free and IDE is more developed than TCC

Compiling a C library so it can be used in an iPhone static library

I've never done this before, so I'm not sure where to even start. I have a few projects where I want to use the liblio library, both on the iPhone and OS X. I've put the installation instructions in a gist.
Here are my questions, and I'll try and edit these questions as I figure them out.
Do I want to use make install to compile these files? I feel like all the compilation should be done within XCode.
It looks like there are a lot of platform specific settings during compilation. How do I control this from XCode?
It seems like I should be able to add all the .h/.m files to my XCode project and compile them myself. Is this missing something?
For the record, I'm aware of a few LibLO libraries created for use on the iPhone. I may break down and use one, but I'd prefer to learn how to do this myself.
Yes, if you want to compile these projects from within XCode, you need to add the .c/.h files and then setup them accordingly. XCode has support for passing argument to the compiler of course, so it is indeed possible.
From the gist snippet, it looks like the installation instructions are GNU standard instructions, ie. configure; make; make install. You could try playing with arguments to configure (which, btw, creates the Makefile on the spot) and see what options you have for compiling to a different target platform.
However, it may not be worth all the trouble to convert the Makefile's to a pure XCode project. Another approach, which I think I would start with, is to hack the created Makefile until you are able to compile an iPhone friendly lib-file. After that you can tell XCode to run 'make ...' as part of your projects build steps. Then, once you understand the issues, it may be easier to include them in your XCode project proper.
I have not tried this myself, but Building autoconf-configured libraries for iPhone OS might have some useful information for you.

Good IDE/compiler for simple C dll's

I'm trying to disassemble a C/C++ DLL, and have made some progress, but I would like to create my own C DLL with the same function the original exports, and compare disassemblies.
Visual Studio adds to much crap, and when I remove the crap and build my project, the expected DLL is missing.
I need a lightweight, preferably IDE, tool to edit and build very simple C libraries.
Take a look at Code::Blocks
I need a lightweight, preferably IDE, tool to edit and build very simple C libraries.
I have found that one of the best ways to do integrated C-only Win32 development is using the freely available Lcc Win32 Compiler which comes with a built-in IDE, including resource editor.
In fact, it is really very lightweight and can be run from a USB stick with some manual tweaking.
It's indeed a really small download of just 6 mb and you can even download an optional Win32 API help file which is really useful while doing development.
The compiler also comes with a C tutorial, as well as good user documentation detailing how to use the integrated Win32 resource editor "wedit", there's also an advanced manual about more complex development tasks.
Dev-C++ is a nice and fast IDE which works well with MingW.
But it's all been asked and answered before ...
MinGW adds its own crap. Install your VC express properly and save yourself a lifetime of trouble.
Btw, you don't need to use Visual Studio for its compiler or vice versa. The oddity of missing a build dll is probably because you are not looking at the right path.
If you are building C DLLs you really would benefit from its command line toolset and utilities, sdks, easy config etc. MS lock-in proprietary extensions are widely used (in context of you trying to emulate another dll), and last thing you need is chasing cross compiler issues..
GCC + any text editor such as VIM is a very light alternative.
For Windows Development, all you need is inside MinGW
Edit: If you are in dire need of an IDE you can also use the MinGW tools from Eclipse with the CDT plugin. Although it adds weight to the solution because of the installation of Eclipse, this is what I really use to build my small DLLs (JNI wrappers in my case).
You can setup your small and direct makefiles or let Eclipse do it automatically for you and concentrate only on the source files (*.h, *.c).
The best part of using this approach instead other IDE is that you do not need Eclipse to further build the DLL, since the underlying project files generated are standard ones directly usable by integrated dev inside MinGW (or any Unix distro) such as make, configure, automake, and so on.
I'll second the vote for Code::Blocks, it's what I use (despite having VS 2008 installed as well). It is very simple and lightweight but has basically all the features you'd expect out of an IDE. It comes with several predefined project templates for all kinds of C and C++ development, including templates for DLLs.
Download the version that includes MinGW and you get a complete lightweight IDE ready to start compiling. You can also easily configure it to use the Visual Studio compiler instead of gcc if you prefer.
try Open Watcom. A cross-platform product, well-supported by the community, lets you develop in DOS, Windows, OS/2 etc for a lot of platforms. Version 1.8 was released recently. Has a light-weight IDE indeed

Resources