I created a package with the curl lib. However the curl functions I am using are not recognized during compilation! Shouldn't they be in the lib?!
The program I am trying to cross compile is running perfectly in my pc
This is the output of:
make -j1 V=sc package/mqtt_exemplo2/compile
mqtt_exemplo2.o: In function `main':
mqtt_exemplo2.c:(.text.startup+0x2f): undefined reference to `curl_global_init'
mqtt_exemplo2.c:(.text.startup+0x35): undefined reference to `curl_easy_init'
mqtt_exemplo2.c:(.text.startup+0x52): undefined reference to `curl_easy_setopt'
mqtt_exemplo2.c:(.text.startup+0x5b): undefined reference to `curl_easy_perform'
mqtt_exemplo2.c:(.text.startup+0x67): undefined reference to `curl_easy_strerror'
mqtt_exemplo2.c:(.text.startup+0x87): undefined reference to `curl_easy_cleanup'
mqtt_exemplo2.c:(.text.startup+0x8d): undefined reference to `curl_global_cleanup'
collect2: error: ld returned 1 exit status
make[3]: *** [makefile:10: mqtt_exemplo2] Error 1
I found this link with what is a patch to fix a similar problem, but I don't know how to apply it nor if it is current since it is 3 years old.
All the help to make curl work in my package will be deeply appreciated!
For completeness I share here my package makefile:
include $(TOPDIR)/rules.mk
# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=mqtt_exemplo2
PKG_VERSION:=1.0
PKG_RELEASE:=1
# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/joao/Documents/myStuff/energiasolar.pt/dev/mqtt_exemplo2
include $(INCLUDE_DIR)/package.mk
# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/mqtt_exemplo2
SECTION:=examples
CATEGORY:=Examples
DEPENDS:=+libcurl
TITLE:=exemplo de MQTT client
endef
# Package description; a more verbose description on what our package does
define Package/mqtt_exemplo2/description
A simple "mqtt client 2" -application.
endef
# Package preparation instructions; create the build directory and copy the source code.
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
$(Build/Patch)
endef
# Package build instructions; invoke the GNU make tool to build our package
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)"
endef
# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/mqtt_exemplo2/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mqtt_exemplo2 $(1)/usr/bin
endef
# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,mqtt_exemplo2))
My guess is that your compile step is faulty. You are trying to override the default compile logic with your own simplified step. Possibly you have overlooked some variable that is needed.
You could try deleting the whole compile section, as it is usually quite unnecessary.
The default compile us then used.
Do you know what is causing this? Was it because I deleted as you suggested?
Without the curl reference, the package was being created and installing without any problems.
When you build your own packages, they and their dependencies need to be transferred to the target and installed. It looks like you’re trying to mix your package with dependencies from the OpenWrt repo
Compiling in the 18.06.1 still doesn't work. I am compiling for "linux build system" because I am running it in virtualbox. However compiling in 18.06.2 works and I was able to install and run on the target system.
Many thanks to all that helped me to sort this out in this and the other threads. Specially to @jeff, @hnyman, @joaohcca, @anon50098793, ...