Temat: kompilacja pakietu

cześć 

mam takie pytanie teoretyczne, używam pod linuksem   programu QT Creator    czy gdyby podać  mu ścieżkę kompilatora    gcc  openwrt z toolchaina   to  dało by się skompilować  jakieś programy ?

2

Odp: kompilacja pakietu

Tak właśnie są kompilowanego programy pod openwrt...

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

3

Odp: kompilacja pakietu

co jeszcze muszę podać   w QT Creator  poza kompilatorem  mips-openwrt-linux-uclibc-gcc   ze skompilowanego  SDK   na dany  router  ?

po wyborze kompilatora  program się  buduje  jednak na openwrt  nie działa

root@Gargoyle:~/test# ./program
./program: line 1: syntax error: unexpected "("

 
ale za to na debianie śmiga tongue

4

Odp: kompilacja pakietu

Jesteś pewien, że zbudowałeś na odpowiednią platformę?

5

Odp: kompilacja pakietu

To znaczy że wcale to nie skompilowałeś kroskompilatorem pod openwrt tylko zwykłym kompilatorem. Zrób pakiet pod openwrt normalnie i kompiluj pod sdk, jak nie to sprawdź czy kompilator, linker i reszta to faktycznie jest mips-openwrt-linux-uclibc-*

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

6

Odp: kompilacja pakietu

no  daje   linux embedded    i potem w zestawie narzędzi gdy wybieram  kompilator   do daje ADI   mips/amr   linux  generic elf

ale  w sumie  po chwili  wszystko wraca na unknown

7

Odp: kompilacja pakietu

Czyli de facto, jak pisze Cezary, nie odwołuje się do środowiska budowy firmware tylko do własnych headers (zazwyczaj systemowych i/lub Qt) - wbrew pozorom "przymuśić" Qt Creator/QT Develop do takiego zadania to wcale nie jest taka "fraszka"...

8

Odp: kompilacja pakietu

czy mógłby ktoś zerknąć czy ten Makefile  jest ok dla helloworld'a  cpp

 ##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to 
# specify a basic description of the package, 
# where to build our program, where to find 
# the source files, and where to install the 
# compiled program on the router. 
# 
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and 
# there should be no trailing whitespace in
# lines that are not commented.
# 
##############################################

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1


# This specifies the directory where we're going to build the program.  
# The root build directory, $(BUILD_DIR), is by default the build_mipsel 
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)


include $(INCLUDE_DIR)/package.mk

# Specify package information for this program. 
# The variables defined here should be self explanatory.
# If you are running Kamikaze, delete the DESCRIPTION 
# variable below and uncomment the Kamikaze define
# directive for the description below
define Package/helloworld
       SECTION:=utils
       CATEGORY:=Utilities
       TITLE:=Helloworld -- prints a snarky message
      # DESCRIPTION:=\
       If you can't figure out what this program does, \\\
       you're probably brain-dead and need immediate \\\
       medical attention.
endef


# Uncomment portion below for Kamikaze and delete DESCRIPTION variable above
define Package/helloworld/description
   If you can't figure out what this program does, you're probably
   brain-dead and need immediate medical attention.
endef


# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
       mkdir -p $(PKG_BUILD_DIR)
       $(CP) ./src/* $(PKG_BUILD_DIR)/
endef


#########################################################################################
# The Build/Compile directive needs to be specified in order to customize compilation
# and linking of our program.  We need to link to uClibc++ and to specify that we 
# do NOT want to link to the standard template library.
#
# To do this we define the LIBS variable.  To prevent linking to the standard libraries we 
# add "-nodefaultlibs" to the $(LIBS) variable and then specify "-lgcc -lc" to ensure that 
# there are no unresolved references to internal GCC library subroutines. Finally 
# "-luClibc++" to link to the  uClibc++ library.  Note the capital C in that flag, as
# this flag is case sensitive.  Also, we need to specify "-nostdinc++" 
# in the compiler flags to tell the compiler that c++ standard template library functions
# and data structures will be linked to in specified external libraries and not the 
# standard libraries.
#########################################################################################
define Build/Compile
       $(MAKE) -C $(PKG_BUILD_DIR) \
                LIBS="-nodefaultlibs -lgcc -lc -luClibc++" \
                LDFLAGS="$(EXTRA_LDFLAGS)" \
                CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CPPFLAGS) -nostdinc++" \
                $(TARGET_CONFIGURE_OPTS) \
                CROSS="$(TARGET_CROSS)" \
                ARCH="$(ARCH)" \
                $(1);
endef

# Specify where and how to install the program. Since we only have one file, 
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running 
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install 
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the 
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
        $(INSTALL_DIR) $(1)/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef


# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))

po dostaje komunikat   

 make[2]: Leaving directory `/home/cyniu/programy_c/attitude_adjustment/package/toolchain'
make[2]: Entering directory `/home/cyniu/programy_c/attitude_adjustment/package/helloworld'
Makefile:111: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.
make[2]: Leaving directory `/home/cyniu/programy_c/attitude_adjustment/package/helloworld'
make[1]: *** [package/helloworld/compile] Error 2
make[1]: Leaving directory `/home/cyniu/programy_c/attitude_adjustment'
make: *** [package/helloworld/compile] Błąd 2
cyniu@debian-cyniu:~/programy_c/attitude_adjustment$ 

a nie ma nigdzie Taba   ;/

9

Odp: kompilacja pakietu

did you mean TAB instead of 8 spaces?

10

Odp: kompilacja pakietu

Masz spacje zamiast tabulacji po prostu. Na wcięciach.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

11

Odp: kompilacja pakietu

e mój  głupi  błąd  ale po wstawieniu  tabulacji  i tak nie działa  smile    walcze dalej

12

Odp: kompilacja pakietu

A co teraz?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

13 (edytowany przez cyniu88 2014-06-11 07:49:16)

Odp: kompilacja pakietu

dalej  kompilator  nie mógł  znaleźć  biblioteki libstdc++.so.6     ale znalazłem gdzieś  info   by skopiować z rutera do katalogu  z kompilatorem bibliotekę  6.0,16   i zrobić  linka  6 do 6.0,16  ( moglem porypać numerki bo pisze z głowy)   no i teraz kompiluje sie już helloword z <iostream>

14

Odp: kompilacja pakietu

Nie rób tego. Raz że libstdcpp masz standardowo, dwa - masz albo źle makefile pakietu zrobiony albo sam makefile, no powinieneś to zlinkować z uclibc++

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

15

Odp: kompilacja pakietu

jak  wrócę do domu to na to popatrzę.    a jest  może jakaś paczka    z kodem cpp  żeby pooglądać  makefile'a ? i czy ewentualnie ten    jest dobry https://github.com/airplug/airplug/wiki … or-OpenWRT

16

Odp: kompilacja pakietu

Mogę zrobić po południu tak samo jak zrobiłem helloword

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

17

Odp: kompilacja pakietu

a w zasadzie dla czego używać  uclibc++  a nie  libstdc++  ?

18

Odp: kompilacja pakietu

Bo libstdc++ ma 824KB a libuclibc++ ma 183KB. Wystarczający powód smile. Taki sam jak używa się uclibc zamiast libc.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

19

Odp: kompilacja pakietu

Masz przykładowy pakiet: http://dl.eko.one.pl/projekty/helloworld-cpp.tar.gz

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

20

Odp: kompilacja pakietu

dzięki  smile  będzie mi  światłem  w tunelu

21

Odp: kompilacja pakietu

Cezary napisał/a:

Bo libstdc++ ma 824KB a libuclibc++ ma 183KB. Wystarczający powód smile....

czy właśnie też  dla tego   obie biblioteki  radzą sobie z  #include <fstream>  ale  z    fstream jakis_plik;     już  tylko libstdc++   ?

22

Odp: kompilacja pakietu

To już w dokumentacji zobacz. uclibc++ oczywiście nie implementuje wszystkiego.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

23 (edytowany przez cyniu88 2015-01-25 20:37:03)

Odp: kompilacja pakietu

czy jeśli  chciałbym skompilować pakiet używający bibioteki libpthread
to makefile z katalogu src  ma zawierać wpis "-libpthread"

iDom_server:iDom_server.o
    $(CXX) $(LDFLAGS) iDom_server.o -o iDom_server $(LIBS) -libpthread
iDom_server.o:iDom_server.cpp
    $(CXX) $(CXXFLAGS) -c iDom_server.cpp 
clean:
    rm *.o iDom_server

czy może przekazywane jest to przez zmienną  $(LIBS)  z głownego makefile ??
w moim głównym makefile'u  nie widzę takiej zmiennej


i  dwa


jak zrobić   by program był obsługiwany przez polecenie

/etc/init.d/program  stop/start/restart     

i sam dodawał się po instalacji do autostartu ?

24

Odp: kompilacja pakietu

1. -lpthread
2. Napisać skrypt do /etc/init.d

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

25

Odp: kompilacja pakietu

Cezary napisał/a:

1. -lpthread

Tak to wiem mam to dopisane w makefile w katalogu src i działa zastanawiam się tylko czy tak ma być czy ma to być przekazane przez zmienna