Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ARM processor #33

Answered by Theldus
anudeep010291 asked this question in Q&A
Discussion options

Can I use this for ARM processor?

You must be logged in to vote

Yes you can. It works fine for both 32 and 64 bits.
I've managed to run without any problems on smartphones, raspberry and etc =).

Replies: 1 comment 9 replies

Comment options

Yes you can. It works fine for both 32 and 64 bits.
I've managed to run without any problems on smartphones, raspberry and etc =).

You must be logged in to vote
9 replies
Comment options

I setup the cross-compiler environment in ubuntu and i replaced the CC=arm-none-gnueabi-gcc

I am unable to generate a lib file compatible for the ARM device..I got the same error..

lib/libws.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status

This is the architecture for the libws.a file i got now

root@mindlogic-VirtualBox:/home/mindlogic/wsServer# readelf -h libws.a | grep 'Class|File|Machine'
File: libws.a(base64.o)
Class: ELF32
Machine: ARM
File: libws.a(handshake.o)
Class: ELF32
Machine: ARM
File: libws.a(sha1.o)
Class: ELF32
Machine: ARM
File: libws.a(utf8.o)
Class: ELF64
Machine: Advanced Micro Devices X86-64

File: libws.a(ws.o)
Class: ELF32
Machine: ARM

Comment options

This is the error i got using once CC was replaced with arm-none-gnueabi-gcc

collect2: error: ld returned 1 exit status
Makefile:35: recipe for target 'send_receive' failed
make[1]: *** [send_receive] Error 1
make[1]: Leaving directory '/home/mindlogic/wsServer/example'
Makefile:93: recipe for target 'examples' failed
make: *** [examples] Error 2

Comment options

File: libws.a(utf8.o)
Class: ELF64
Machine: Advanced Micro Devices X86-64

This is quite strange, utf8.c is not built differently from the others so that its architecture is not the same as the others. Does the error persist when doing a clean build? (make clean && make)

A clean build here works as expected (testing for OpenRISC, architecture doesn't really matter):

$ export CC=or1k-linux-musl-gcc
$ make clean
make[1]: Entering directory '/home/theldus/anudeep_ws/example'
make[1]: Leaving directory '/home/theldus/anudeep_ws/example'
make[1]: Entering directory '/home/theldus/anudeep_ws/tests'
make[1]: Leaving directory '/home/theldus/anudeep_ws/tests'
make[1]: Entering directory '/home/theldus/anudeep_ws/tests/fuzzy'
make[1]: Leaving directory '/home/theldus/anudeep_ws/tests/fuzzy'
$ make -j8
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/base64/base64.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/base64/base64.o
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/handshake/handshake.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/handshake/handshake.o
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/sha1/sha1.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/sha1/sha1.o
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/ws.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/ws.o
ar cru libws.a /home/theldus/anudeep_ws/src/base64/base64.o /home/theldus/anudeep_ws/src/handshake/handshake.o /home/theldus/anudeep_ws/src/sha1/sha1.o /home/theldus/anudeep_ws/src/utf8/utf8.o /home/theldus/anudeep_ws/src/ws.o
make -C example/
make[1]: Entering directory '/home/theldus/anudeep_ws/example'
or1k-linux-musl-gcc -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/example/..//include -std=c99 -pthread -pedantic send_receive.c -o send_receive /home/theldus/anudeep_ws/example/..//libws.a
make[1]: Leaving directory '/home/theldus/anudeep_ws/example'
$ readelf -h libws.a | grep -P 'Class|File|Machine'
File: libws.a(base64.o)
 Class: ELF32
 Machine: OpenRISC 1000
File: libws.a(handshake.o)
 Class: ELF32
 Machine: OpenRISC 1000
File: libws.a(sha1.o)
 Class: ELF32
 Machine: OpenRISC 1000
File: libws.a(utf8.o)
 Class: ELF32
 Machine: OpenRISC 1000
File: libws.a(ws.o)
 Class: ELF32
 Machine: OpenRISC 1000

edit: utf8.o was not being deleted with make clean, so it mixed with your build for AMD64. Fix already pushed to the master.

collect2: error: ld returned 1 exit status
Makefile:35: recipe for target 'send_receive' failed
make[1]: *** [send_receive] Error 1
make[1]: Leaving directory '/home/mindlogic/wsServer/example'
Makefile:93: recipe for target 'examples' failed
make: *** [examples] Error 2

The example file should also be compiled for ARM, when configuring CC properly:

$ CC=or1k-linux-musl-gcc make -j8
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/base64/base64.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/base64/base64.o
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/handshake/handshake.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/handshake/handshake.o
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/sha1/sha1.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/sha1/sha1.o
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/utf8/utf8.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/utf8/utf8.o
or1k-linux-musl-gcc /home/theldus/anudeep_ws/src/ws.c -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/include -std=c99 -pedantic -DVALIDATE_UTF8 -c -o /home/theldus/anudeep_ws/src/ws.o
ar cru libws.a /home/theldus/anudeep_ws/src/base64/base64.o /home/theldus/anudeep_ws/src/handshake/handshake.o /home/theldus/anudeep_ws/src/sha1/sha1.o /home/theldus/anudeep_ws/src/utf8/utf8.o /home/theldus/anudeep_ws/src/ws.o
make -C example/
make[1]: Entering directory '/home/theldus/anudeep_ws/example'
or1k-linux-musl-gcc -Wall -Wextra -O2 -I /home/theldus/anudeep_ws/example/..//include -std=c99 -pthread -pedantic send_receive.c -o send_receive /home/theldus/anudeep_ws/example/..//libws.a
make[1]: Leaving directory '/home/theldus/anudeep_ws/example'
$ file example/send_receive
example/send_receive: ELF 32-bit MSB executable, OpenRISC, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-or1k.so.1, not stripped

What is your full build output?

What do you get if you use CMake? CMake is certainly smarter than me at writing correct Makefiles, so the chances of working are greater...

$ mkdir build
$ cd build
$ CC=arm-none-gnueabi-gcc cmake ..
$ make

As a last resort, you can 'cheat' too. The wsServer source code is small enough for you to compile fully manually, something like the following must work:

#!/bin/bash
CC=arm-none-gnueabi-gcc
INCLUDE="$PWD/include"
CFLAGS=(-Wall -Wextra -O2 -I"$INCLUDE" \
	-std=c99 -pedantic -DVALIDATE_UTF8)
$CC "$PWD"/src/base64/base64.c ${CFLAGS[@]} -c -o "$PWD"/src/base64/base64.o
$CC "$PWD"/src/handshake/handshake.c ${CFLAGS[@]} -c -o "$PWD"/src/handshake/handshake.o
$CC "$PWD"/src/sha1/sha1.c ${CFLAGS[@]} -c -o "$PWD"/src/sha1/sha1.o
$CC "$PWD"/src/utf8/utf8.c ${CFLAGS[@]} -c -o "$PWD"/src/utf8/utf8.o
$CC "$PWD"/src/ws.c ${CFLAGS[@]} -c -o "$PWD"/src/ws.o
ar cru libws.a "$PWD"/src/base64/base64.o\
	"$PWD"/src/handshake/handshake.o\
	"$PWD"/src/sha1/sha1.o\
	"$PWD"/src/utf8/utf8.o\
	"$PWD"/src/ws.o
# Example file
$CC "$PWD"/example/send_receive.c -I"$INCLUDE" -o send_receive "$PWD"/libws.a

Save the above shell script in the wsServer root folder and run it.

Comment options

Thank you so much. It is working now. Replaced the CC with arm-none-linux-gnueabi-gcc

Now the got the corrrect architecture and it is working fine in the embedded device as well..Thank you for your help

mindlogic@mindlogic-VirtualBox:~/wsServer$ readelf -h libws.a | grep -P 'Class|File|Machine'
File: libws.a(base64.o)
Class: ELF32
Machine: ARM
File: libws.a(handshake.o)
Class: ELF32
Machine: ARM
File: libws.a(sha1.o)
Class: ELF32
Machine: ARM
File: libws.a(utf8.o)
Class: ELF32
Machine: ARM
File: libws.a(ws.o)
Class: ELF32
Machine: ARM

Comment options

I'm glad you managed to make it work =).

Answer selected by Theldus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /