|
This is a linker question.
Could somebody help me to decode this linker verbose output to find WHERE is the " linked to" option actually located.
Building target: BLUE2_LINUX_19381
Invoking: GCC C++ Linker
g++ -v -o "BLUE2_LINUX_19381" ./src/BLUE.o -lbluetooth
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.11' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'BLUE2_LINUX_19381' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/ccFV22zV.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o BLUE2_LINUX_19381 /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. ./src/BLUE.o -lbluetooth -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o
Finished building target: BLUE2_LINUX_19381
08:15:26 Build Finished. 0 errors, 1 warnings. (took 2s.946ms)
I did try this and cannot find it:
jim@jim-desktop:~$ sudo find /usr -type f -name "bluetooth.*"
[sudo] password for jim:
/usr/share/help-langpack/en_GB/ubuntu-help/bluetooth.page
/usr/share/help-langpack/cs/ubuntu-help/bluetooth.page
/usr/share/help-langpack/cs/gnome-help/bluetooth.page
/usr/share/help-langpack/en_AU/ubuntu-help/bluetooth.page
/usr/share/help-langpack/en_CA/ubuntu-help/bluetooth.page
/usr/share/man/man1/bluetooth.1.gz
/usr/share/icons/Humanity/apps/22/bluetooth.svg
/usr/share/icons/Humanity/apps/48/bluetooth.svg
/usr/share/icons/Humanity/apps/24/bluetooth.svg
/usr/share/icons/HighContrast/48x48/apps/bluetooth.png
/usr/share/icons/HighContrast/16x16/apps/bluetooth.png
/usr/share/icons/HighContrast/22x22/apps/bluetooth.png
/usr/share/icons/HighContrast/24x24/apps/bluetooth.png
/usr/share/icons/HighContrast/32x32/apps/bluetooth.png
/usr/share/icons/HighContrast/256x256/apps/bluetooth.png
/usr/share/app-install/icons/bluetooth.svg
/usr/share/help/C/ubuntu-help/bluetooth.page
/usr/share/help/C/gnome-help/bluetooth.page
/usr/share/plainbox-provider-checkbox/jobs/bluetooth.txt.in
/usr/include/bluetooth/bluetooth.h
/usr/src/linux-headers-4.15.0-45/include/net/bluetooth/bluetooth.h
/usr/src/linux-headers-4.15.0-46/include/net/bluetooth/bluetooth.h
jim@jim-desktop:~$ sudo find /usr -type f -name "bluetooth.a"
jim@jim-desktop:~$
I am trying to figure out how BlueZ is actually used , so I did purge Bluez.
There is no package "Bluez".
Before that I fully configured Bluez - and I added enable-library to the configuration.
I did not even run make make install and tested my app and it run with the -lbluetooth linker option.
It appears the "bluetooth" library was build by running BlueZ -> configure and "purge Bluez" won't delete it.
I like to prove this by deleting it manually, but need to know where it is.
There is no package "Bluez".
But my test app still compiles / links and runs.
Thanks
|
|
|
|
|
Not sure exactly what your question is, but "make clean" should purge all the generated objects. To be honest you may get better answers at The BlueZ website[^]; that's where the knowledge is likely to be.
This is the key:
g++ -v -o "BLUE2_LINUX_19381" ./src/BLUE.o -lbluetooth
A pre-linker is creating a new library object called BLUE2_LINUX_19381 , which you can see later being included in the main link process.
|
|
|
|
|
Richard,
that is my base site , however, I have not figured out if there is a "forum" for geeks like me.
All I see is "developers" access.
I'll try it again.
|
|
|
|
|
On the contact page there's link to the mailing list in the "community for the end users" section.
|
|
|
|
|
As has been explained before, -lbluetooth tells the linker to look for a library file named either libbluetooth.so or libbluetooth.a. Your find doesn't find it because -name option uses standard file globbing so -name "bluetooth.*" wont find any files that look like .../libbluetooth.a . You need to use -name "libbluetooth.*" , or -name "*bluetooth.*"
I think you said you had built and installed bluez from source. Unless you changed the installation location, it probably put the libraries under /usr/local. When you purged bluez (I'm assuming you mean the command apt-get delete --purge bluez ), that will only remove the packages installed by apt. Any packages you built and installed yourself will not be touched (unless you deliberately configured the package to overwrite the system packages).
|
|
|
|
|
Not exactly. No "apt-get".
The README instructions with BlueZ are
1. run "configure" and then
2. run "make && make install".
Their default "configure " is this:
jim@jim-desktop:/media/jim/DEV/BLUEZ/bluez-5.50$ ./configure --prefix=/usr \
> --sysconfdir=/etc \
> --localstatedir=/var \
> --enable-library \
> --disable-systemd &&
> make
I did added the "enable-library" but apparently it is not needed.
And I do not know the actual name of it , but the liker likes it.
So the /usr is the base directory and "*bluetooth*" should be there.
I'll run make && make install to verify the "BlueZ" package , again.
I'll will be adding --host= (ARM) later so I really need to know what is happening with "install library". I could end up with two "bluetooth.a" for two architectures...messy
|
|
|
|
|
using --prefix=/usr put all the generated files in /usr. If you still have your build directory, you should be able to remove everything with using make uninstall . If you've already deleted your build directory, then unpack the source again, re-run configure as you did before, then run make uninstall . Note that installing into /usr means that you've overwritten anything that apt installed previously, so you might end up with the apt thinking thinking that some of its files have gone missing. If you plan to build a cross-compilation library DO NOT USE --prefix=/usr. That will overwrite the X86 executables, libraries, etc with the ARM versions, which will lead to further pain on your part. If you still want to create a cross-compile bluez instalation, use --prefix=/usr/local/arm --sysconfdir=/usr/local/arm/etc --localstatedir=/usr/local/arm/var . Of course, you can use any path you wish in place of "/usr/local/arm", just not "/usr" or "/", as that will overwrite your X86 system files.
|
|
|
|
|
Am I correct to say that /usr is a common Linux directory ,used by other applications?
So I should be able to "insert " another directory - such as --prefix=/usr/X86 for the X86 architecture and --prefix =/usr/ARM for the ARM?
Such as you suggested using /usr/local/arm....?
What would be the advantage of inserting ../local/ ..?
I should take a look at "configure prefix".
|
|
|
|
|
There's no reason you can't use /usr/X86 and /usr/ARM, if that's your wish, its not likely to cause problems for your linux system. In general, though, its a convention, nothing more, to put user-compiled software in /usr/local. If you run .configure for most software packages they default to --prefix=/usr/local. I suggested /usr/local/arm as that fits in with the accepted convention. Ultimately, you have root permissions, and can put things where you like. The one caveat, though, is if you put things in /[bin|lib], or /usr/[bin|lib] you run the risk of a) making your system unusable due to overwriting system provided executables or libraries with incompatible version and b) having your executables and libs reverted back to OS versions when updating software. For me, I think I'd put anything new I compiled for the X86 in /usr/local, as the compiler and linker will search /usr/local/include and /usr/local/lib, without having to add -I/usr/local/include or -L/usr/local/lib to compilation commands. I think /usr/local/arm or /usr/local/pi seems a reasonable location to put the ARM versions.
|
|
|
|
|
Another thing: If you have a successful compile/link AND you're linking shared libraries (.so), you can find out which version of the library will be used using the ldd command
e.g
rpi:~$ ldd /usr/bin/find
linux-vdso.so.1 (0x7eff1000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f53000)
libselinux.so.1 => /lib/arm-linux-gnueabihf/libselinux.so.1 (0x76f0c000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76e8d000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76d4e000)
/lib/ld-linux-armhf.so.3 (0x76f69000)
libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0x76cd5000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76cc2000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76c99000)
|
|
|
|
|
Nice , but now I know which library was build by package and thatit the one linker will use so I do not have to search for it.
|
|
|
|
|
I am beginning to wonder if Linux "Open (source) " is really beneficial.
The following code snippet just stops executing, and I get no perror.
I like to analyze the source code for "hci_inquiry" function to get some idea way it is failing.
num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags);
if (num_rsp < 0)
perror("Error: hci_inquiry");
.
I have found numerous versions / copies of BlueZ docs with this preamble
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2000-2001 Qualcomm Incorporated
* Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@holtmann.org>
*
*
MOST of them lack comments describing the function I am after.
My question to forum users :
Which Linux resource , in general , is most likely to be updated and best documented?
Github?
|
|
|
|
|
Vaclav_ wrote: Which Linux resource , in general , is most likely to be updated and best documented? The one that is. Seriously, the only way to find out is to look at them all. My idea of 'best' may not tally with yours.
|
|
|
|
|
|
This is not a question , just sort of FYI if anybody cares.
Instead of futzing with crosscomplier I have decided to build a local bluetooth application.
I have purged "bluez" from my X86 system.
I have left the "-lbluetooth" linker option intact.
I can compile / link and run the app and get expected errors from accessing basic stuff - such as
dev_id = hci_get_route(NULL); if (dev_id < 0) {
perror("Bluetooth device not found"); }
Next I'll be reinstalling / configuring / make / make install "bluez" , again.
In theory that should get rid of most of the errors without touching the "-lbluetooth" option.
|
|
|
|
|
The following TEST snippet works just fine, however, since the "hci_inquiry" itself generate the expected perror why does the code continues to run and not exiting AFTER "hci_inquiry"?
It does exits AFTER the last test of num_rsp, as expected.
num_rsp = hci_inquiry(dev_id, len, max_rsp, NULL, &ii, flags);
if( num_rsp < 0 ) perror("Error: hci_inquiry");
if( num_rsp < 0 ) perror(NULL);
Here is the expected output:
Error: hci_inquiry: No such device
No such device
hci_inquiry: No such device
|
|
|
|
|
|
Sorry ,but how does that answer my question about exiting after perror?
I do not see anything indicating it should exit.
|
|
|
|
|
Take another look, it tells you exactly what perror does in the description: Quote: The perror() function produces a message on standard error describing
the last error encountered during a call to a system or library
function.
|
|
|
|
|
After reading this resource www.bluez.org I am trying to figure out how or if it is possible to control implementation of “libbluetooth-dev” on selected architecture.
The “bluez” README suggest some options, but after downloading and scanning thru “configure” file itself I am not sure where to find “configure” dependency on underlying architecture.
The “configure” is several hundred pages long and to be honest - I am little lost where to start.
I also checked this http://www.linuxfromscratch.org/blfs/view/8.3/general/bluez.html but it did not help me.
Any suggestion to accomplish the task will be appreciated.
PS
At present I hesitate to download the “configure” file here – it is too big.
Cheers
Vaclav
Addendum
I think this will answer my question
Cross Compiling BlueZ Bluetooth tools for ARM - BeyondLogic[^]
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.18.tar.xz
tar -xJf bluez-5.18.tar.xz
cd bluez-5.18
./configure --host=arm-linux-gnueabi --prefix= PKG_CONFIG_PATH=/usr/arm-linux-gnueabi/lib/pkgconfig --disable-systemd --disable-udev --disable-cups --disable-obex --enable-library
make
make install DESTDIR=/usr/arm-linux-gnueabi
make install DESTDIR=/home/export/rootfs
modified 6-Mar-19 18:17pm.
|
|
|
|
|
|
The proverbial "chicken or egg".
Knowing the term (host) makes the search child's play.
Thanks.
|
|
|
|
|
Hi,
A bit of background:
I recently worked out how to cross compile/build/flash ESP32 projects ( C/C++ ) from my windows 10 machine, from a virtual Ubuntu machine and from a colleague's Apple OSX ( sierra ) machine.
Once I had it up and running on all those platforms from their respective Command line shells ( Using the mingw32 shell on the Windows machine ) I made a set of JSON configuration files for VSCODE that works equally well on all mentioned platforms so that I can use VSCODE to get IDE like functionality.
As I have a Raspberry PI3B and some time for the time being I would like to repeat the same experiment for the raspberry PI. If I can find a way to compile/build/flash C/C++ projects from the mingw command line for the raspberry PI I am sure I could set up VSCODE to provide a sort of IDE functionality for any PI project.
I already have the required "arm-linux-gnueabihf" toolchain but in spite of there being tons of info out there a simple example for say a "hello world" applicaton which uses "make" and a "makefile" is near impossible to find, at least I have not found it.
Any help/pointer much appreciated and if I do succeed I will post how I pulled it off.
|
|
|
|
|
I have been doing same - crosscompiling C++ "between" X86 (Ubuntu) and RPi 3B ( ARM).
I am using Eclipse IDE with Target Communication Framework - TCF.
Not the best setup.
Eclipse C++ IDE is being "updated" at breakneck speed and nobody does QA.
TCF is an orphant with no real relations with Eclipse "foundation".
It has been time consuming process to make Eclipse and TCF to play together.
And to answer your request and be brutally honest - I have not found a single resources explaining how crosscompiling works.
My latest "task" is to crosscomplie ( still X86 ) with a library build for ARM. See this forum.
Talking about a mess.
Cheers
Vaclav
|
|
|
|
|
 Ain't that the truth, like anything to do with Linux you find bits and pieces at various locations but nothing solid.
I the mean time I have cobbled some things together and I am able to run a make command which appears to produce an output but I am not sure yet it runs on a raspberry PI.
Anyway: I can run "make" which uses this makefile:
TARGET_EXEC ?= a.out
BUILD_DIR ?= ./build
SRC_DIRS ?= ./main
SYSROOT = /c/msys32/home/RPI/SysGCC/arm-linux-gnueabihf/sysroot
CROSS_COMPILE = /C/msys32/home/RPI/SysGCC/bin/arm-linux-gnueabihf
CXX = $(CROSS_COMPILE)-g++ --sysroot $(SYSROOT)
CC = $(CROSS_COMPILE)-gcc --sysroot $(SYSROOT)
AS = $(CROSS_COMPILE)-as
AR = $(CROSS_COMPILE)-ar
NM = $(CROSS_COMPILE)-nm
LD = $(CROSS_COMPILE)-ld
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS)
# assembly
$(BUILD_DIR)/%.s.o: %.s
$(MKDIR_P) $(dir $@)
$(AS) $(ASFLAGS) -c $< -o $@
# c source
$(BUILD_DIR)/%.c.o: %.c
$(MKDIR_P) $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
# c++ source
$(BUILD_DIR)/%.cpp.o: %.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
.PHONY: clean
clean:
$(RM) -r $(BUILD_DIR)
-include $(DEPS)
MKDIR_P ?= mkdir -p
Most of it comes from here:
A Super-Simple Makefile for Medium-Sized C/C++ Projects[^]
It has some merits as it automatically finds and builds any "c" files located in the "main" directory as specified and any "c" files in any subdirectories.
The bit with the SYSROOT comes from here:
http://www.lilug.org/w/images/e/e6/T_Rothamel_Presentation_CrossCompiling_8_Jul_2014.pdf[^]
It appears to build my hello_world_main.c in directory main, my test.c file in directory main/test and produces the specified a.out file in the Build directory. During the process it calls the necessary arm-linux-gnueabihf-gcc cross development tool so I guess it might just be an operational executable for the Raspberry PI. I will know more tomorrow.
|
|
|
|