Simple Hello World in Objective-C with clang and gnustep does not compile - objective-c

System:
64bit Ubuntu Lucid
GNUStep
clang/LLVM
test.m
#import <Foundation/Foundation.h>
int main(int argc, char * argv[]){
NSLog(#"Hello world!\n");
return 0;
}
compile command line:
clang -fobjc-gc -I /usr/lib/gcc/x86_64-linux-gnu/4.4.3/include -I /usr/include/GNUstep/ -I /usr/lib/gcc/x86_64-linux-gnu/4.4.3/include-fixed/ -L /usr/lib/GNUstep/ -L /usr/lib64/ -fconstant-string-class=NSConstantString -rpath /usr/lib64 -Xlinker -lgnustep-base test.m -o Test
error:
/usr/bin/ld: /usr/lib64//libgnustep-base.so: undefined reference to symbol '__objc_exec_class'
/usr/bin/ld: note: '__objc_exec_class' is defined in DSO /usr/lib64/libobjc.so.2 so try adding it to the linker command line
/usr/lib64/libobjc.so.2: could not read symbols: Invalid operation
clang: error: linker command failed with exit code 1 (use -v to see invocation)
While using GCC, it compiles fine, but clang does not.

On a fresh install of Ubuntu 12.10 I installed the following packages:
$ sudo apt-get install build-essential
$ sudo apt-get install clang
$ sudo apt-get install gnustep
$ sudo apt-get install gnustep-make
$ sudo apt-get install gnustep-devel
$ sudo ln -s /usr/lib/gcc/i686-linux-gnu/4.7/include/objc /usr/local/include/objc
(the final symlink is required to properly locate the objc.h header)
Then I compiled the test.m file as follows:
$ clang -o test test.m -I `gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS` \
-L `gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARIES` \
-lgnustep-base -fconstant-string-class=NSConstantString \
-D_NATIVE_OBJC_EXCEPTIONS \
-lobjc
tux#ubuntu:~/Desktop$ ./test
2012-11-20 11:02:08.184 test[11856] Hello world!
* EDIT
On a fresh 10.04-64bit this allows to compile just fine:
$ sudo apt-get install build-essential
$ sudo apt-get install clang
$ sudo apt-get install gnustep-devel
$ sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/4.4.3/include/objc/ /usr/local/include/objc

Related

Apache httpd compile (make) error. How to fix it?

I get an error when compiling (configure) Apache httpd. Please tell me how to solve it.
Error message
$ git clone -b 2.2.3 --single-branch https://github.com/apache/httpd.git
$ cd httpd
$ autoconf
$ ./configure
configure: error: cannot find required auxiliary files: config.guess config.sub
My environment
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
$ autoconf -V
autoconf (GNU Autoconf) 2.71
Update 1
The "configure" problem has probably been solved. (I stopped using github). However, an error occurs during make.
"make" error message
$ wget https://archive.apache.org/dist/httpd/httpd-2.2.3.tar.gz
$ gzip -d httpd-2.2.3.tar.gz
$ tar xvf httpd-2.2.3.tar
$ cd httpd-2.2.3
$ ./configure --prefix /home/ubuntu/local
$ make
/usr/bin/ld: .libs/htpasswd.o: undefined reference to symbol 'crypt##XCRYPT_2.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcrypt.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:39: htpasswd] Error 1
make[2]: Leaving directory '/home/ubuntu/httpd-2.2.3/support'
make[1]: *** [/home/ubuntu/httpd-2.2.3/build/rules.mk:72: all-recursive] Error 1
make[1]: Leaving directory '/home/ubuntu/httpd-2.2.3/support'
make: *** [/home/ubuntu/httpd-2.2.3/build/rules.mk:72: all-recursive] Error 1
Installed modules
sudo apt-get install libapr1-dev libaprutil1-dev
sudo apt-get install build-essential
sudo apt-get install libpcre3-dev
Try this:
wget http://archive.apache.org/dist/httpd/httpd-2.2.3.tar.gz
tar -xf httpd-2.2.3.tar.gz
sudo ./configure --prefix=/opt/httpd --with-included-apr --with-ssl=/opt/openssl-1.0.1i --enable-ssl-staticlib-deps --enable-mods-static=ssl
sudo make
sudo make install

How to compile apache2 own module in dockerfile?

I want to compile my own Apache module when building my image, so i wrote the following Dockerfile.
FROM httpd:2.4.25
COPY conf/httpd.conf /usr/local/apache2/conf/httpd.conf
COPY modules/mod_example.c /usr/local/apache2/modules/mod_example.c
RUN apxs -i -a -c modules/mod_example.c
EXPOSE 80
But i get an error :
/usr/share/apr-1.0/build/libtool --silent --mode=compile x86_64-linux-gnu-gcc -std=gnu99 -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/local/apache2/include -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include -c -o mod_example.lo mod_example.c && touch mod_example.slo
/usr/share/apr-1.0/build/libtool: line 1114: x86_64-linux-gnu-gcc: command not found
apxs:Error: Command failed with rc=65536
I tried apt-get install gcc or libtool it say it's unable to locate the package.
My goal is to compile the ".c" file in a ".so" file.
Installing gcc, or the build-deps of say libapr1, is all that's needed. You probably just have a problem with your unspecified attempt at adding the compiler from your dockerfile.
For referene, here's how the httpd layer adds the compiler:
https://github.com/docker-library/httpd/blob/master/2.4/Dockerfile
I needed to do an apt-get update then :
apt-get install build-essential libtool
Since the docker image is a prod image, it doesn't contain dev tools.

Can I build my PC file (Oracle Pro*c) conditionally inside of my application's make file?

I'm attempting to combine my makefiles so I can simply build once and it will precompile the pc file completely before continuing to build the application. This should be possible but for the life of me I cannot figure it out. Here is my makefile (for redhat 7).
COMPILEDATE = $(shell date)
COMPILE=g++ -std=c++11 -Wall -Wuninitialized -g
OSTYPE = $(shell uname)
LIBDIR=../../lib/
INC=../../include/
FILES=myProcess
OBJS= myProcess.o \
sqlStuff.o
O8P=$(ORACLE_HOME)
O8P=/u01/app/oracle/11.2.0/client_1
ORACLE_HOME=/u01/app/oracle/11.2.0/client_1
PROC_LINES=proc lines=yes code=ANSI_C iname=sqlStuff.pc parse=partial iname=sqlStuff include=. include=$(ORACLE_HOME)/precomp/public include=$(ORACLE_HOME)/rdbms/public include=$(ORACLE_HOME)/rdbms/demo include=$(ORACLE_HOME)/plsql/public include=$(ORACLE_HOME)/network/public
all: $(FILES)
compileInfo.o : FORCE
$(COMPILE) -c compileInfo.cpp -o $# -I$(INC) -DCDATE="\"$(COMPILEDATE)\"" -DBUILD="\"$(LSWBUILD)\""
FORCE :
%.o : %.cpp $(INC)myProcess.h
$(COMPILE) -c $< -o $# -I$(INC) -DCDATE="\"$(COMPILEDATE)\""
sqlStuff.o : sqlStuff.c
gcc -g -Wall -O -c -lclntsh -I. -I$(ORACLE_HOME)/precomp/public -I$(ORACLE_HOME)/rdbms/public -I$(ORACLE_HOME)/rdbms/demo -I$(ORACLE_HOME)/plsql/lib -I$(ORACLE_HOME)/network/lib
sqlStuff.c : sqlStuff.pc
$(PROC_LINES)
myProcess: $(OBJS) $(LIBDIR)libbase.a $(INC)myProcess.h sqlStuff.o
$(COMPILE) -o myProcess$(OBJS) -L$(LIBDIR) -lbase
clean:
rm -f $(FILES)
rm -f sqlStuff
rm -f sqlStuff.c
rm -f sqlStuff.lis
rm -f $(OBJS)
rm -f core
rm -f *.out
rm -f *.log
rm -f *.err
My fault, I didn't explain what the issue was:
I'm compiling in netbeans using this build command: ${MAKE} -f Makefile. The error is PCC-S-02015, unable to open include file on my object that is not being precompiled, sqlStuff.o
Looking at the gcc command under sqlStuff.o : sqlStuff.c, it looks to me that there should be a -o sqlStuff.o flag to tell gcc that the output should be written to sqlStuff.o instead of the default, which is a.out.
Best of luck.

Using hiredis (redis client library)

I have the redis server installed, and can use it from the command line. Now, I am wanting to write a client program using hiredis. To begin with, I tried to compile example.c which is present in the hiredis directory:
vishal#expmach:~/redis-2.6.14/deps/hiredis$ ls
adapters async.h COPYING dict.h *example.c* example-libevent.c
hiredis.c Makefile net.h sds.c test.c async.c CHANGELOG.md dict.c example-
ae.c example-libev.c fmacros.h hiredis.h net.c README.md sds.h
Here are the commands:
vishal#expmach:~/redis-2.6.14/deps/hiredis$ gcc -c -I hiredis example.c
vishal#expmach:~/redis-2.6.14/deps/hiredis$ gcc -o example -I hiredis -L hiredis -lhiredis -lm
/usr/bin/ld: cannot find -lhiredis
collect2: ld returned 1 exit status
I am not sure how to go about fixing this. Please help.
gcc -o example example.c -lhiredis $(pkg-config --cflags --libs glib-2.0)
why don't you juste juste the provided Makefile?
make
./hiredis-example

using homebrew apxs from homebrew apache httpd24 fails with libtool: compile: unable to infer tagged configuration

using homebrew apxs from homebrew apache httpd24 fails with libtool: compile: unable to infer tagged configuration
$ apxs -i -c -Wc,"-arch x86_64" -Wl,"-arch x86_64 " mod_uwsgi.c
/usr/share/apr-1/build-1/libtool --silent --mode=compile cc -prefer-pic -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/local/Cellar/httpd24/2.4.3/include/apache2 -I/usr/include/apr-1 -I/usr/include/apr-1 -arch x86_64 -c -o mod_uwsgi.lo mod_uwsgi.c && touch mod_uwsgi.slo
libtool: compile: unable to infer tagged configuration
libtool: compile: specify a tag with `--tag'
apxs:Error: Command failed with rc=65536
.
What environment must I export to have libtool not complain about tag?
after digging through the source I found that if LTFLAGS is set to --tag=cc things work.
$ LTFLAGS=--tag=cc apxs -i -c mod_uwsgi.c