IBM AIX 7.1 unable to compile with gtk2-2.24.30-2 - aix

I have tried to install GTK2 on my IBM AIX7.1 from AIX Toolbox for Linux Applications. It offers me gtk2-2.24.30-2waixX11 so I have intalled it via rpm -i.
Now I have just simple empty main.c which only includes GTK2.
#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
return 0;
}
When I try to compile my example, using:
gcc -maix64 main.c `pkg-config --cflags gtk+-2.0`
It returns me an error:
In file included from /usr/include/sys/thread.h:41:0,
from /usr/include/sys/ptrace.h:28,
from /usr/include/sys/proc.h:42,
from /usr/include/sys/pri.h:43,
from /usr/include/sys/sched.h:38,
from /usr/include/sched.h:51,
from /usr/include/pthread.h:63,
from /home/run/tools/include/glib-2.0/glib/deprecated/gthread.h:128,
from /home/run/tools/include/glib-2.0/glib.h:108,
from /home/run/tools/include/glib-2.0/gobject/gbinding.h:28,
from /home/run/tools/include/glib-2.0/glib-object.h:23,
from /home/run/tools/include/glib-2.0/gio/gioenums.h:28,
from /home/run/tools/include/glib-2.0/gio/giotypes.h:28,
from /home/run/tools/include/glib-2.0/gio/gio.h:26,
from /home/run/tools/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
from /home/run/tools/include/gtk-2.0/gdk/gdk.h:32,
from /home/run/tools/include/gtk-2.0/gtk/gtk.h:32,
from main.c:1:
/home/run/tools/include/gtk-2.0/gtk/gtktypeutils.h:61:24: error: expected ';', ',' or ')' before '.' token
gpointer func_data);
^
/home/run/tools/include/gtk-2.0/gtk/gtkwindow.h:443:36: error: expected ';', ',' or ')' before '.' token
gpointer func_data);
It continues with the same error over more header. It seems that gpointer is unknown for GTK headers? I even have tried to add glib include into gtktypeutils.h, typedef void* gpointer definition into the same file or I have chaged gpointer to void*. Bus it returns always the same problem.
Here are my glib and gtk packages:
rpm -qa | grep gtk
gtk2-2.24.30-2waixX11
gtk2-devel-2.24.30-2waixX11
rpm -qa | grep glib
glib2-2.56.1-2
glib2-devel-2.56.1-2
Do you heve some idea? Thanks, Jiri.

In AIX, symbol func_data is also defined in /usr/include/sys/timer.h as t_union.data unless you define symbol _LINUX_SOURCE_COMPAT (I cannot tell what other consequences this definition might have):
gcc -maix64 main.c -D_LINUX_SOURCE_COMPAT `pkg-config --cflags gtk+-2.0`
Or rather, you could edit the header files in question, something like this:
perl -pi.bak -e 's/func_data/pfunc_data/g' \
$(grep -l func_data $(find pathto/gtk/ -name '*.h'))

Related

How did Cygwin g++ resolve it?

I am puzzled how a mere g++ -o testpoco testpoco.cpp -lPocoFoundation was able to compile successfully in my Cygwin environment. The complete C++ code is below:
#include <Poco/File.h>
int main (int argc, char *argv[])
{
Poco::File f("/tmp/test.log");
if (f.exists()) {
return 1;
}
return 0;
}
I installed the cygwin Poco development headers and libraries and I verified they are in:
/usr/include/Poco/ (the header files)
/usr/lib/ (the libraries)
But without specifying those include and library path in g++ how did it was able to compile and produce the exe? I checked the output of g++ -v and did not see any routes to Poco.
The compiler has default search paths for include files and for libraries. (Actually the latter applies to the linker, not the compiler, but the g++ command invokes both.)
/usr/include and /usr/lib are in those default search paths.
You specified #include <Poco/File.h>, so the compiler found /usr/include/Poco/File.h.
You specified -lPocoFoundation, so the linker found /usr/lib/libPocoFoundation.dll.a, the file that contains the code implementing the PocoFoundation library under Cygwin.
I checked the output of g++ -v and did not see any routes to Poco
The command g++ -v will just print out some version information about GCC, and how it was configured. Adding the -v option to your real commands used for compiling and/or linking will show the search paths for headers and libraries.
In other words, instead of just g++ -v you should try:
g++ -o testpoco testpoco.cpp -lPocoFoundation -v
This will show the search paths that Keith Thompson refers to in his answer.

Unsatisfied linker error when linking with openssl libraries built for Android

Am getting the following error when linking with openssl libs (ssl/crypto) with my Android native code. I used openssl v1.0.2l code and built it using ndk-build available under android-sdk/ndk-bundle directory.
Error Info
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pkg-name.client, PID: 26925
java.lang.UnsatisfiedLinkError: **dlopen failed: cannot locate symbol "i2d_DHxparams"** referenced by "/data/app/com.pkg-name.client-1/lib/arm/libnative-lib.so"...
My android-config.make file has the following:
#
# These flags represent the build-time configuration of openssl for android
#
# They were pruned from the "Makefile" generated by running ./Configure from import_openssl.sh
#
# From CLFAG=
LOCAL_CFLAGS += -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -O3 -fomit-frame-pointer -Wall #-DTERMIO
# From DEPFLAG=
LOCAL_CFLAGS += -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_SCTP \
-DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CAPIENG -DOPENSSL_NO_CAST -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_SHA0 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SEED -DOPENSSL_NO_STORE -DOPENSSL_NO_WHIRLPOOL
#Copied by seaching for the OPENSSL_NO_
#LOCAL_CFLAGS += -DOPENSSL_NO_DEPRECATED
# Extra
LOCAL_CFLAGS += -DOPENSSL_NO_HW -DOPENSSL_NO_ENGINE -DZLIB
# Debug
# LOCAL_CFLAGS += -DCIPHER_DEBUG
Please let me know if I need to enable any flag.
I tried the pre-built openssl library for Android and getting similar issues.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pkg-name.client, PID: 26925
java.lang.UnsatisfiedLinkError: **dlopen failed: cannot locate symbol "i2d_DHxparams"**
referenced by "/data/app/com.pkg-name.client-1/lib/arm/libnative-lib.so"...
i2d_DHxparams is a macro in OpenSSL 1.1.0, not 1.0.2:
$ cd openssl
$ grep -IR i2d_DHxparams
crypto.map: i2d_DHxparams;
util/libcrypto.num:i2d_DHxparams 2206 1_1_0 EXIST::FUNCTION:DH
doc/man3/d2i_X509.pod:i2d_DHxparams,
include/openssl/dh.h:# define i2d_DHxparams_fp(fp,x) \
include/openssl/dh.h: ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x))
include/openssl/dh.h:# define i2d_DHxparams_bio(bp,x) \
include/openssl/dh.h: ASN1_i2d_bio_of_const(DH, i2d_DHxparams, bp, x)
include/openssl/dh.h:int i2d_DHxparams(const DH *a, unsigned char **pp);
crypto/dh/dh_ameth.c: return i2d_DHxparams(a, pp);
crypto/dh/dh_asn1.c:int i2d_DHxparams(const DH *dh, unsigned char **pp)
apps/dhparam.c: i = i2d_DHxparams_bio(out, dh);
It sounds like you might be using the wrong headers or library. Perhaps you have 1.1.0 headers on-path and they are being picked up before the Android headers.
EDIT: It looks like the symbol is present in OpenSSL 1.0.2, too:
$ git checkout OpenSSL_1_0_2-stable
$ grep -IR i2d_DHxparams
crypto.map: i2d_DHxparams;
util/libeay.num:i2d_DHxparams 4683 EXIST::FUNCTION:DH
crypto/dh/dh.h:# define i2d_DHxparams_fp(fp,x) \
crypto/dh/dh.h: ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x))
crypto/dh/dh.h:# define i2d_DHxparams_bio(bp,x) \
crypto/dh/dh.h: ASN1_i2d_bio_of_const(DH, i2d_DHxparams, bp, x)
crypto/dh/dh.h:int i2d_DHxparams(const DH *a, unsigned char **pp);
crypto/dh/dh_ameth.c: return i2d_DHxparams(a, pp);
crypto/dh/dh_asn1.c:int i2d_DHxparams(const DH *dh, unsigned char **pp)
apps/dhparam.c: i = i2d_DHxparams_bio(out, dh);
But it does not appear to be present in 1.0.1:
$ grep -IR i2d_DHxparams
crypto.map: i2d_DHxparams;

Objective C compiling with clang on Linux Foundation/Foundation.h linking: file not found

I'm trying to compile a program in Objective C on Ubuntu, I have installed GNUstep, set all the GNUSTEP_* environment variables, and installed clang, because I read that gcc can't compile Objective-C code with blocks (Objective-C 'anonymous' functions, just to be clear: ^ { }).
What I get when I run this command:
clang hello.m -o hello
Is:
hello.m:1:9: fatal error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>
^
1 error generated.
I tried this also:
clang -L '/usr/include/GNUstep/Foundation/Foundation.h' hello.m -o hello
Where /usr/include/... is the path to the Foundation.h file on my system; but I still get the same result.
How can I link those header files automatically and compile Objective-C?
Thanks!
You can use gnustep-config:
clang `gnustep-config --objc-flags` `gnustep-config --objc-libs` hello.m -o hello

How to compile objc code on Linux?

Assuming you have your .h and .m ready on a Linux server, which command would you issue to GCC to have it compiled?
The relevant parts:
gcc -c -Wno-import List.m
gcc -o prog -Wno-import List.o main.o -lobjc
. . . make sure that the Objective-C library and header files (objc/Object.h) were installed when gcc was built.
Note that when linking Objective-C with gcc, you need to specify the Objective-C library by using the -lobjc switch.
See this link for more information.
Additional link with possible solution to the missing compiler issue:
Try installing either gobjc++ or gobjc
sudo apt-get install gobjc++
gcc -x objective-c file.m -o out
Google is your friend

Help with GCC and ObjectiveC code and Cygwin

Is it possible to build objective c code correctly with GCC under cygwin.
I have the following application that should work on a Mac environment, but can't get the most basic stuff to work with gcc. Are there more libraries I need to have.
#import "HelloWorldApp.h"
int main(int argc, char *argv[]) {
return 0;
} // End of the //
#interface Car
{
int test;
}
//The registration is a read-only field, set by copy
#property int (readonly, copy) test;
//the driver is a weak reference (no retain), and can be modified
//#property Person* (assign) driver;
#end
CC=gcc
CXX=gcc-g++
LD=$(CC)
CFLAGS=
LDFLAGS=-lobjc
all: HelloWorld
HelloWorld: HelloWorld.o
$(LD) $(LDFLAGS) -o $# $^
%.o: %.m
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $#
clean:
rm -rvf *.o HelloWorld HelloWorld.exe
Error:
gcc -c HelloWorld.m -o HelloWorld.o
In file included from HelloWorld.m:6:
HelloWorldApp.h:19: error: stray '#' in program
HelloWorldApp.h:19: error: parse error before "int"
make: *** [HelloWorld.o] Error 1
I think it's because you're using Objective-C 2.0, which is a private extension that Apple developed and that they did not contribute back to the "standard", FSF GCC. Thus, your mingw compiler (which is not based on Apple's, but on the FSF's) does not understand new syntax like properties.
# Malaxeur - you hit the nail right on the head. I've just been bashing about with ObjC on a PC and had that exact problem - my path was pointing to a v3.x gcc compiler. I switched to the 4.x version and voila!
It's also worth noting that the "stray '#'" error also pops up if you spell 'implementation' wrong, which is a little misleading.
Anyway, thanks for the help.
Have you tried running the gcc commands directly from command line rather than via makefile?
Found this reference:
Taken directly from http://www.cs.indiana.edu/classes/c304/ObjCompile.html
Compiling Objective-C
Objective-C code can be compiled using the GNU C compiler gcc. Objective-C interface files usually marked by the extension .h as in List.h. Implementation files are usually marked by the extension .m as in List.m. The implementation file should #import its corresponding interface file. Your main program should also #import the interface files of all of the classes it uses.
Usually, you will want to compile the files which implement your classes separately. For instance, to compile List.m, use the following command:
gcc -c -Wno-import List.m
The -c switch tells the compiler to produce an object file, List.o, which can then later be linked into your program. Do this for each of your implementation files, and your main program.
The -Wno-import switch tells the compiler not to give a warning if you have a #import statement in your code. For some reason, Richard Stallman (the GNU Project founder) doesn't like the #import construction.
When you are ready to compile your program, you can link all of the implementations of your classes using gcc again. For example, to compile the files List.o, and main.o you could use the following command:
gcc -o prog -Wno-import List.o main.o -lobjc
The -o prog tells gcc to create an executable program with the name prog (if you do not specify this, it will default to a.out.
Note that when linking Objective-C with gcc, you need to specify the Objective-C library by using the -lobjc switch. If gcc reports an error, contact your system administrator to make sure that the Objective-C library and header files (objc/Object.h) were installed when gcc was built.