OpenWrt Forum Archive

Topic: GCC for OpenWrt trunk

The content of this topic has been archived between 30 Mar 2018 and 13 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
im actually running OpenWrt trunk Version r47532 on my Raspberry Pi. It might be a stupid question but i searched on the package list and in this forum but found no Information, if there is a version of gcc available for trunk. I checked the packagelist but i can´t find it. Before running trunk i had installed the Chaos Calmer version which had a gcc package. But i need some packages which are easier to install on trunk than CC so i compiled them in the SDK on a linux computer. But now i need to compile a package on my Pi. For this i have to run the config before and there i get the message that there is no compiler which it can use. So my question is where can i get gcc for my trunk version and how do i implement it to my System. I already tried to build it from scratch but i also can´t find the package there. Also i tried to build it as a package but when compiling in the SDK there are also some librarys missing and i don´t know how i can add them to the SDK. If someone could tell me what i have to to or tell me how i can add Packages to the SDK it would be very nice.

Thanks in advance

R U wanting to to build a native GCC for your platform? If so, you will also need to build the libc library package. Without the later, you can only compile your source file into an object file and won't be able to link any object files to produce an executable binary file that required the libc library (see the NOTE2 below to see about the quick hack to get the musl and/or uClibc header and/or library files). If this is what you need, then go to Development sub-menu (under make menuconfig) and GCC is there (depends on which platform is supported). In the Development sub-menu, you will also find some other development libraries and/or tools needed to support GCC. However, I don't think you will find any musl and/or uClibc libraries there.

NOTE1: If your trunk also has feeds from the old packages repo, it should have a package called build-essentials. When this package is enabled, it will select all the GCC and/or required libraries / tools to compile with NO_STRIP option. When building a native compiler + libraries, it is probably important not to have the libraries stripped. If you don't have the old_package feeds, you can add it to your feed.conf file (src-git old_packages git://git.openwrt.org/packages.git) and then run a scripts/feeds update -a; scripts/feeds install -a to update your trunk with old_packages feeds.

NOTE2: For musl and/or uClibc, perhaps this quick hack will work, i.e. copy the header and library files from your $(TOOLCHAIN_DIR)/{lib,usr/{include,lib}} to your platform.

Hi,
Thank you very much for your help. I managed to get the old packages and enabled build-essential package. And there i got the musl/uClibc problem as you said before. But i don´t really understand your Note2 which header and library files from which folder do i have to put in which folder on my platform? (i simply don´t get the paths) And by Toolchain you mean that one used from the Imagebuilder or the external one?

Thank you in advance

(Last edited by Taulin on 27 Nov 2015, 14:30)

When expanded, $(TOOLCHAIN_DIR)/{lib,usr/{include,lib}} means $(TOOLCHAIN_DIR)/lib, $(TOOLCHAIN_DIR)/usr/include, and $(TOOLCHAIN_DIR)/usr/lib directories. These directories are filled with all the toolchains files needed to compile and/or build OpenWRT. Take a look at the <OpenWRT root directory>/rules.mk file and it will tell you what the TOOLCHAIN_DIR is. This is platform, gcc, and musl or uClibc specifics. I my case with a Marvell Kirkwood platform using gcc-4.8 + uClibc, my TOOLCHAIN_DIR is <OpenWRT root directory>/staging_dir/toolchain-arm_xscale_gcc-4.8-linaro_uClibc-1.0.8_eabi . Yours will probably be different.. BTW, you will still need to select the gcc package to build a gcc native compiler for your target platform.

Hi,
thank you again i found those folders but only the $(TOOLCHAIN_DIR)/lib folder contains files which i copied to my platform. The folders $(TOOLCHAIN_DIR)/usr/include and /usr/lib haven´t any files which i can copy to my platform.

My toolchain Directory is almost like yours <OpenWrt root>/staging_dir/toolchain-arm1176jzf-s+vfp_gcc-4.8-linaro_uClibic-1.0.8_eabi. I also select the gcc package but on compile i get following error

-L/home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/binutils-2.24/bfd/../libiberty/pic -liberty ../libiberty/libiberty.a -lz
tc-arm.o: In function `s_ltorg':
tc-arm.c:(.text+0x15118): undefined reference to `_obstack_newchunk'
cond.o: In function `s_ifdef':
cond.c:(.text+0x1f8): undefined reference to `_obstack_newchunk'
cond.c:(.text+0x2d4): undefined reference to `_obstack_newchunk'
cond.o: In function `s_if':
cond.c:(.text+0x580): undefined reference to `_obstack_newchunk'
cond.o: In function `s_ifb':
cond.c:(.text+0x740): undefined reference to `_obstack_newchunk'
cond.o:cond.c:(.text+0x920): more undefined references to `_obstack_newchunk' follow
cond.o: In function `s_endif':
cond.c:(.text+0xd70): undefined reference to `obstack_free'
cond.o: In function `s_ifeqs':
cond.c:(.text+0x1028): undefined reference to `_obstack_newchunk'
cond.o: In function `cond_exit_macro':
cond.c:(.text+0x1354): undefined reference to `obstack_free'
frags.o: In function `frag_alloc':
frags.c:(.text+0xc8): undefined reference to `_obstack_newchunk'
frags.c:(.text+0x130): undefined reference to `_obstack_newchunk'
frags.o: In function `frag_append_1_char':
frags.c:(.text+0x7bc): undefined reference to `_obstack_newchunk'
hash.o: In function `hash_new_sized':
hash.c:(.text+0x158): undefined reference to `_obstack_begin'
hash.c:(.text+0x178): undefined reference to `_obstack_newchunk'
hash.o: In function `hash_die':
hash.c:(.text+0x21c): undefined reference to `obstack_free'
hash.o: In function `hash_insert':
hash.c:(.text+0x284): undefined reference to `_obstack_newchunk'
hash.o: In function `hash_jam':
hash.c:(.text+0x370): undefined reference to `_obstack_newchunk'
hash.o: In function `hash_delete':
hash.c:(.text+0x530): undefined reference to `obstack_free'
read.o: In function `read_begin':
read.c:(.text+0x10e4): undefined reference to `_obstack_begin'
read.c:(.text+0x1108): undefined reference to `_obstack_begin'
read.o: In function `demand_copy_string':
read.c:(.text+0x4aec): undefined reference to `_obstack_newchunk'
read.c:(.text+0x4b18): undefined reference to `_obstack_newchunk'
stabs.o: In function `s_stab_generic':
stabs.c:(.text+0x3b8): undefined reference to `obstack_free'
subsegs.o: In function `subsegs_begin':
subsegs.c:(.text+0x48): undefined reference to `_obstack_begin'
subsegs.o: In function `subseg_set_rest':
subsegs.c:(.text+0x1c4): undefined reference to `_obstack_newchunk'
subsegs.c:(.text+0x270): undefined reference to `_obstack_begin'
symbols.o: In function `save_symbol_name':
symbols.c:(.text+0x3c): undefined reference to `_obstack_newchunk'
symbols.o: In function `local_symbol_make':
symbols.c:(.text+0x144): undefined reference to `_obstack_newchunk'
symbols.o: In function `decode_local_label_name':
symbols.c:(.text+0xb9c): undefined reference to `_obstack_newchunk'
symbols.o: In function `symbol_create':
symbols.c:(.text+0x19ec): undefined reference to `_obstack_newchunk'
symbols.o: In function `symbol_clone':
symbols.c:(.text+0x1ce0): undefined reference to `_obstack_newchunk'
write.o:write.c:(.text+0x70): more undefined references to `_obstack_newchunk' follow
collect2: error: ld returned 1 exit status
Makefile:753: recipe for target 'as-new' failed
make[8]: *** [as-new] Error 1
make[8]: Leaving directory '/home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/binutils-2.24/gas'
Makefile:2165: recipe for target 'all-recursive' failed
make[7]: *** [all-recursive] Error 1
make[7]: Leaving directory '/home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/binutils-2.24/gas'
Makefile:682: recipe for target 'all' failed
make[6]: *** [all] Error 2
make[6]: Leaving directory '/home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/binutils-2.24/gas'
Makefile:4710: recipe for target 'all-gas' failed
make[5]: *** [all-gas] Error 2
make[5]: Leaving directory '/home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/binutils-2.24'
Makefile:830: recipe for target 'all' failed
make[4]: *** [all] Error 2
make[4]: Leaving directory '/home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/binutils-2.24'
Makefile:120: recipe for target '/home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/binutils-2.24/.built' failed
make[3]: *** [/home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/binutils-2.24/.built] Error 2
make[3]: Leaving directory '/home/debian/SDKTrunk/openwrt/package/devel/binutils'
package/Makefile:191: recipe for target 'package/devel/binutils/compile' failed
make[2]: *** [package/devel/binutils/compile] Error 2
make[2]: Leaving directory '/home/debian/SDKTrunk/openwrt'
package/Makefile:188: recipe for target '/home/debian/SDKTrunk/openwrt/staging_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/stamp/.package_compile' failed
make[1]: *** [/home/debian/SDKTrunk/openwrt/staging_dir/target-arm_arm1176jzf-s+vfp_uClibc-1.0.8_eabi/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/debian/SDKTrunk/openwrt'
/home/debian/SDKTrunk/openwrt/include/toplevel.mk:177: recipe for target 'world' failed
make: *** [world] Error 2

I searched for the solution and the only one i found is already implemented and does not help.

thanks in advance

I know it has something to do with the obstack.h file but as i said i just found one solution but it is already implemented. But i still have this problem but i have several ideas so i gonna try them.
Had anyone the same problem like me and solved it?? It would save me much time and would be a great help

Thanks

Sorry that I can't help you on those error messages. sad You will probably need to sift through Google to find out what others have to say about those error messages.

No Problem you really helped me a lot i already managed to get out this error message by taking out some packages(v4l-utils brought this message) on the compile process. I will add them later on an other way.
I finished to compile my version successfully. I just slept by typing the size of the Image and put in 4GB root size and working with a 4GB sd card which hasn´t a full 4GB size so i first need to make  the Image smaller (wich i actually working on it) and after that i can test the ima´ge with a hopefully working gcc.
So thank you very much for your help

greetings

NP. Please let us know how it goes.

Well today i tested my trunk Version but i still got problems with gcc... I first tired to compile a package wich i put on my system but on it´s /.configure script i get an error like "C compiler cannot create executables".
So i tried to compile a simple hello world programm and tried with:

cc -o helloworld helloworld.c

but i get an error message which says cc not found.
i checked with gcc -v if it´s even installed and got that output which says that it should be installed

root@OpenWrt:~# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-openwrt-linux-muslgnueabi/4.8.3/lto-wrapper
Target: arm-openwrt-linux-muslgnueabi
Configured with: /home/debian/SDKTrunk/openwrt/build_dir/target-arm_arm1176jzf-s+vfp_musl-1.1.11_eabi/gcc-4.8.3/configure --target=arm-openwrt-linux --host=arm-openwrt-linux --build=x86_64-linux-gnu --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --build=x86_64-linux-gnu --host=arm-openwrt-linux-muslgnueabi --target=arm-openwrt-linux-muslgnueabi --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 4.8.3' --enable-shared --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --disable-libmudflap --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/usr --libexecdir=/usr/lib
Thread model: posix
gcc version 4.8.3 (OpenWrt GCC 4.8.3)

So maybe there is a wrong path or something else is wrong with my installation. If anyone can help me it would be very nice.

Thanks

Ok it seems like the C compiler isn´t even installed.
After the command

ls -l /usr/bin

i get a lot of programs listed and i can find
c++ -> arm-openwrt-Linux-muslgnueabi-g++
and
gcc -> arm-openwrt-linux-muslgnueabi-gcc
but there should also be a line with cc -> gcc...
but there is no entry.
Do i have to choose any Option in the menuconfig?
Normally gcc should contain everything (like c++,c and so on)

So i don´t wonder why my program can´t find cc it seems like it isn´t even installed

EDIT: got also this output by tring to compile my package

/usr/bin/ld: error: a.out uses VFP register arguments, /tmp/ccFBflLI.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccFBflLI.o

(Last edited by Taulin on 2 Dec 2015, 13:19)

I believe cc won't be created by default and you will probably need to mod (Hint: use quilt) the OpenWRT Makefile file for the gcc package to include the creating of cc linked file.

What is your software package? Can it be crossed compiled by OpenWRT?

Taulin wrote:

EDIT: got also this output by tring to compile my package

/usr/bin/ld: error: a.out uses VFP register arguments, /tmp/ccFBflLI.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccFBflLI.o

I don't know if this will help or not.

Thanks for your help,
i can´t cross compile the package because i don´t know how to add already compiled packages to the SDK. My package needs some more other packages. I already compiled them and installed them on my system but i don´t know actually how to add them to the SDK so i can´t  crosscompile my other package and have to compile it on my system.

mazilo wrote:

I don't know if this will help or not.

I already searched for my error and found the same but i guess it has something to do with the missing cc.

mazilo wrote:

I believe cc won't be created by default and you will probably need to mod (Hint: use quilt) the OpenWRT Makefile file for the gcc package to include the creating of cc linked file.

Well that looks complicated to me ... However that will be a lot of work so i think i have to create a patch but i have no plan what i have to put in. And i guess i have to do it after i made my image so i have to add the patch and recompile my OpenWrt Version again right?

And thank you very much for your help im really feeling bad to ask u that much but i simply can´t find any information on the Internet. And i need to get this to run because i need to include a package for a system running in my company.

greetings

Taulin wrote:

i can´t cross compile the package because i don´t know how to add already compiled packages to the SDK. My package needs some more other packages. I already compiled them and installed them on my system but i don´t know actually how to add them to the SDK so i can´t  crosscompile my other package and have to compile it on my system.

Is this your package an open-source? If so, please post the link and I will see if I can try to cross compile it.

mazilo wrote:

I don't know if this will help or not.

I already searched for my error and found the same but i guess it has something to do with the missing cc.

mazilo wrote:

I believe cc won't be created by default and you will probably need to mod (Hint: use quilt) the OpenWRT Makefile file for the gcc package to include the creating of cc linked file.

Well that looks complicated to me ... However that will be a lot of work so i think i have to create a patch but i have no plan what i have to put in. And i guess i have to do it after i made my image so i have to add the patch and recompile my OpenWrt Version again right?

You do NOT have to use quilt! If the quilt process is rather complicated, you can just manually modify your OpenWRT package Makefile to your taste. AFAICT, quilt is a very useful tool for a developer to maintain modified local source files with patches.

Hi,
my package is open source it´s called ZBar. You already answered me on my other Topic^^ i managed to compile Imagemagick and pkg-config. On trunk everything else is aviable what i need because i don´t need any GUI for it. I gonna have a look for the makefile to modify it  but first im gonna recompile my OS because i did some mistakes on it but shouldn´t be a Problem.
greetings

I searched for the makefile and found different of them but i guess it´s the one under build_dir/target-arm-.../gcc-4.8.3/Makefile
But i have no clue how i can enable the cc for my gcc package. That Makefile is very big and i found some entrys for cc but i don´t find anything about how to enable the cc or even an entry which disable it . Am I searching in the right file or im totally wrong (thats what i guess). It would be very helpful if somebody can tell me how i enable the cc for gcc on Openwrt.

AFAICT, the simplest approach is to use symlink to create a cc file pointed to gcc. For instance, if you are using this gcc package from OpenWRT feeds, all you need is to add a new symlink to create cc from gcc. Please take a look at the patch below and see how I used quilt to simply create the patch file. In the step quilt edit feeds/packages/devel/gcc/Makefile, quilt launched its default editor (vi) for me to add/delete/modify the feeds/packages/devel/gcc/Makefile file. In this case, I added this line ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/cc and save/exit to create the patched file. The feeds-packages-devel-gcc-Makefile.patch file will be created and saved under patches sub-directory. In my settings, it is /opt/openwrt-git-trunk/patches/feeds-packages-devel-gcc-Makefile.patch. You can use quilt pop to un-patch the file and then use quilt push <patched file> to re-patch the file.

[debian@debian:/opt/openwrt-git-trunk 154%] ~ quilt new feeds-packages-devel-gcc-Makefile.patch
Patch feeds-packages-devel-gcc-Makefile.patch is now on top
[debian@debian:/opt/openwrt-git-trunk 155%] ~ quilt edit feeds/packages/devel/gcc/Makefile
File feeds/packages/devel/gcc/Makefile added to patch feeds-packages-devel-gcc-Makefile.patch
[debian@debian:/opt/openwrt-git-trunk 156%] ~ quilt refresh
Refreshed patch feeds-packages-devel-gcc-Makefile.patch
[debian@debian:/opt/openwrt-git-trunk 157%] ~ quilt diff
--- a/feeds/packages/devel/gcc/Makefile
+++ b/feeds/packages/devel/gcc/Makefile
@@ -107,6 +107,7 @@ define Package/gcc/install
        ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/c++
        ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/g++
        ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-c++
+       ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/cc
        ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/gcc
        ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc-$(PKG_VERSION)
        cp -ar $(PKG_INSTALL_DIR)/usr/lib/gcc $(1)/usr/lib
[debian@debian:/opt/openwrt-git-trunk 158%] ~ quilt pop
Removing patch feeds-packages-devel-gcc-Makefile.patch
Restoring feeds/packages/devel/gcc/Makefile

Now at patch zz_config.patch
[debian@debian:/opt/openwrt-git-trunk 159%] ~ quilt push
Applying patch feeds-packages-devel-gcc-Makefile.patch
patching file feeds/packages/devel/gcc/Makefile

Now at patch feeds-packages-devel-gcc-Makefile.patch
[debian@debian:/opt/openwrt-git-trunk 160%] ~

Thank you again, i almost got your solution but without quilt hehe. But thanks to you i knew what to put into the Makefile. I just added the line into the right Makefile and compiled again
Now it installed cc on my system. But however it could just work but no ... now i can install programs but if i wanna use them they are always "not found" i had to change the distfeed on my opkg and installed e.g nano and Luci. But when i wanna use them like e.g nano /etc/config/Network it just says nano not found. Same for Luci, i want to go to the interface like always but the side was not found. I can´t belive that it caused by my modification on the gcc makefile. I also tested the old Image(before modification) and everything worked fine for me. I guess i have to recompile it like the 100th time >.< never thought it would be so hard to get that damn package to work and i knew this wasn´t all for now hehe.

But i recompile tomorrow not now maybe somebody have an idea what to do to avoid it.

greetings

(Last edited by Taulin on 3 Dec 2015, 16:20)

Taulin wrote:

I guess i have to recompile it like the 100th time >.< never thought it would be so hard to get that damn package to work and i knew this wasn´t all for now hehe.

I am sure you would have learnt a lot from this.

Yeah i really lerned a lot from this but it´s kinda frustrating. You work on a problem and almost solved it and the next problem appears on a function wich worked before... I still got that problem like i told before i recompiled my system installed nano (checked also $PATH) and it appears in /usr/bin but i get that error "/bin/ash: nano: not found". On recompile i used the old downloads of the packages because the Proxy of my company is terrible and i always have to change settings to download anything but i don´t think thats the problem. Like i said it was working before and i can´t belive that this causes by adding one line to the gcc makefile. My packages don´t have anything to do with nano. When i add packages from scratch they are working. Just those i installed after compiling wont work. But i can´t add them all on scartch because of the Proxy i just can install them from my running system. But i always have to change the feeddist on my OS because it´s sth like

src/gz designated_driver base....

also the download path is incorrect and i have to change.
Well but this is offtopic need to fix that and i will report back when i test gcc

greetings

Hi again,
i bring this up again because my problem is not solved. I managed to install my packages which i need. I also managed to install cc. I still want to install zbar but i got again this error on my ./configure option :

configure:3314: error: C compiler cannot create executables

and in the config log i have again this message

 configure:3241: checking for C compiler default output file name
configure:3263: gcc    conftest.c  >&5
/usr/bin/ld: error: a.out uses VFP register arguments, /tmp/ccNkcImm.o does not
/usr/bin/ld: failed to merge target specific data of file /tmp/ccNkcImm.o
collect2: error: ld returned 1 exit status

I checked the hard and softfloat point but i simply don´t understand it.
If somebody could help me it would be very nice

Ok i managed that error but now i got following

configure:3241: checking for C compiler default output file name
configure:3263: gcc -mfloat-abi=hard   conftest.c  >&5
configure:3267: $? = 0
configure:3305: result: a.out
configure:3324: checking whether the C compiler works
configure:3334: ./a.out
./configure: line 3336: ./a.out: No such file or directory
configure:3338: $? = 127
configure:3345: error: in `/root/zbar-0.10':
configure:3349: error: cannot run C compiled programs.

my fitst Problem gotta solved by typing

Export CFLAGS="-mfloat-abi=hard"

so i think my next problem has still something to do with the flags path or more in this direction
If somebody knows more let me know

greetings

Whenever I encountered the following error messages spit out by running configure, I always check the configure file to see what those lines, i.e. 3314 and 3336, do. From that, chances are they will tell you a lot of things why they go wrong. For instance on the line 3314, there is a chance configure fails to compile its conftest.c file because of missing some libraries, i.e. -L$(STAGING_DIR)/usr/lib -lz, etc. If this is the case, then probably all you need is to add TARGET_LDFLAGS+= -L$(STAGING_DIR)/usr/lib -lz to the Makefile file of your package and see if that will fix the issue. At least, this is what I will do. Perhaps, others will have a much better solution here.

configure:3314: error: C compiler cannot create executables
configure: line 3336: ./a.out: No such file or directory