gcc

Decompress PNG using zlib

Hi All, How can I use zlib library to decompress a PNG file? I have no idea how to read a PNG file. When I opened a PNG file in TextPad(a text editor), the data was not at all understandable. Is it because a PNG file is compressed? Any help is greatly appreciated. I need to read a PNG file using a C program and gcc compiler. Regards,...

Different ways to specify libraries to gcc/g++

I'd be curious to understand if there's any substantial difference in specifying libraries (both shared and static) to gcc/g++ in the two following ways (CC can be g++ or gcc) CC -o output_executable /path/to/my/libstatic.a /path/to/my/libshared.so source1.cpp source2.cpp ... sourceN.cpp vs CC -o output_executable -L/path/to/my/libs ...

Possible to use a .dll on Linux

Question: Is it possible to compile a program on linux using a .dll file? Where this is going: This .dll will be used to write a php extension to some proprietary software from a third party. Background and Research: I have been given a library called proprietary.lib. I was curious, as I have never seen the .lib extension before, so ...

[GCC, linking] How to link app with static library + why this is not working

I have a problem. I wrote example code and I want to build it without the error: main.cpp(.text+0x5): undefined reference to `test()' Library test1.c #include <stdlib.h> void test() { puts("Działa"); } test1.h #ifndef TEST1_H #define TEST1_H extern void test(); #endif makefile all: gcc -c ./src/test1.c -o ./lib/test1.o ...

On which platforms does libc store stack cookie values somewhere other than __stack_chk_guard?

e.g glibc on Linux/i386 stores the cookie at %gs:0x14. Are there any other platforms on which I need to look somewhere other than at the __stack_chk_guard symbol to find the cookie? (This is where the value that gcc -fstack-protector-generated code stores onto the stack in function prologues and checks before return to defend against st...

Trying to build the LEVMAR math library on a mac using the Accelerate Framework

Hello. I want build levmar-2.5 math library on a mac using the included Makefile. It requires LAPACK, another math library which is included in the Accelerate Framework. I do not know how to modify the Makefile to indicate the location of the library so that it builds correctly. There is a libLAPACK.dylib in the framework. Ultimately...

Incompatible pointer type

Hello. I have the function with following signature: void box_sort(int**, int, int) and variable of following type: int boxes[MAX_BOXES][MAX_DIMENSIONALITY+1] When I am calling the function box_sort(boxes, a, b) GCC gives me two warnings: 103.c:79: warning: passing argument 1 of ‘box_sort’ from incompatible pointer type (string...

Configuring a library to be included with C++ test

Hello, I would like to utilize the UnitTest++ library in a testing file. However, I am having some difficulty getting the library to be included at compile time. So here is my current directory structure: tests/ UnitTests++/ libUnitTest++.a src/ UnitTests++.h unit/ test.cpp I have just used the UnitTest++ gettin...

"Parse error" in struct declaration

I want to use some basic struct in C like the following: struct p { int a; int b; p * next; } However, it fails to compile with an error: parse error before "p" on the line with p * next;. Do you have any idea what the reason could be for this problem? ...

How to write a buffer-overflow exploit in GCC,windows XP,x86?

void function(int a, int b, int c) { char buffer1[5]; char buffer2[10]; int *ret; ret = buffer1 + 12; (*ret) += 8;//why is it 8?? } void main() { int x; x = 0; function(1,2,3); x = 1; printf("%d\n",x); } The above demo is from here: http://insecure.org/stf/smashstack.html But it's not working here: D:\tes...

ld reports missing symbols, but symbols seem to exist

I'm trying to link my mac application to the wonderful libancillary library. However, I have changed the library build script to create a shared library. I can inspect the symbols in this library using nm libancillary.dylib - the result is: libancillary.dylib(single module): U ___sF U __keymgr_get_and_lock_processwide_...

Mac gcc non-virtual thunk error

I'm getting these non-virtual thunk errors only in the Deployment build of my app. It uses a private framework called Lgi. Building on 10.5.8 using XCode 3.1.4 (latest for leopard?) The error looks like this: Ld /Users/matthew/Code/Scribe-Branches/v2.00/build/Development/Scribe.app/Contents/MacOS/Scribe normal i386 cd /Users/matthew...

gcc linker finding both .so and .a in the library path which is chosen?

If I run gcc a.c -L /usr/lib -lexpat and both libexpat.a and libexpat.so are in /usr lib which one is used by the linker? ...

Compiling without libc

I want to compile my C-code without the (g)libc. How can I deactivate it and which functions depend on it? I tried -nostdlib but it doesn't help: The code is compilable and runs, but I can still find the name of the libc in the hexdump of my executable. ...

gcc support libraries fail when cross-compiling

I'm trying to cross-compile gcc 4.4.3 and it's cross libraries. I have set all the Environment Variables needed for cross-compilation (AS, CC, CXX, AR, RANLIB, STRIP) and used the same setup for a lot of other stuff already, all of which worked fine. Now gcc itself also compiles without a problem but the support libraries are really puz...

"call" instruction that seemingly jumps into itself

I have some C++ code #include <cstdio> #include <boost/bind.hpp> #include <boost/function.hpp> class A { public: void do_it() { std::printf("aaa"); } }; void call_it(const boost::function<void()> &f) { f(); } void func() { A *a = new A; call_it(boost::bind(&A::do_it, a)); } which gcc 4 compiles into the following as...

GCC vs Microsoft : Undefined reference to `_chkstk'?

I am using CodeBlocks and MinGW toolchain which is essentially GCC. I was using VStudio but I want to get away from it to do cross platform development. There seems to be some microsoft specific references in some libraries that I am linking, specifically in CXImage SDK (_chkstk). I presume the library was put together using VS. From my ...

memory alignment within gcc structs

I am porting an application to an ARM platform in C, the application also runs on an x86 processor, and must be backward compatible. I am now having some issues with variable alignment. I have read the gcc manual for __attribute__((aligned(4),packed)) I interpret what is being said as the start of the struct is aligned to the 4 byte bo...

Linker error: wants C++ virtual base class destructor

Hi, I have a link error where the linker complains that my concrete class's destructor is calling its abstract superclass destructor, the code of which is missing. This is using GCC 4.2 on Mac OS X from XCode. I saw http://stackoverflow.com/questions/307352/g-undefined-reference-to-typeinfo but it's not quite the same thing. Here is t...

GCC 4.2 Build error

Hi, i am building a C project with Xcode and when ever i build it it gives me this error: ld: duplicate symbol _detectLinux in /Users/markszymanski/Desktop/Programming/C/iTermOS/build/iTermOS.build/Debug/iTermOS.build/Objects-normal/i386/linuxDetect.o and /Users/markszymanski/Desktop/Programming/C/iTermOS/build/iTermOS.build/Debug/iTer...