Berkeley DB: "make install" fails on Linux - linux

I am trying to install Berkeley DB 18.1.40 (C++ version) on my virtual machine (Linux-Ubuntu).
When I do sudo make install, I encounter the following error messages:
Installing DB include files: /usr/local/BerkeleyDB.18.1/include ...
Installing DB library: /usr/local/BerkeleyDB.18.1/lib ...
libtool: install: cp -p .libs/libdb-18.1.so /usr/local/BerkeleyDB.18.1/lib/libdb-18.1.so
libtool: install: cp -p .libs/libdb-18.1.lai /usr/local/BerkeleyDB.18.1/lib/libdb-18.1.la
libtool: install: cp -p .libs/libdb-18.1.a /usr/local/BerkeleyDB.18.1/lib/libdb-18.1.a
libtool: install: chmod 644 /usr/local/BerkeleyDB.18.1/lib/libdb-18.1.a
libtool: install: ranlib /usr/local/BerkeleyDB.18.1/lib/libdb-18.1.a
libtool: install: cp -p libdb.a /usr/local/BerkeleyDB.18.1/lib/libdb.a
libtool: install: chmod 644 /usr/local/BerkeleyDB.18.1/lib/libdb.a
libtool: install: ranlib /usr/local/BerkeleyDB.18.1/lib/libdb.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/BerkeleyDB.18.1/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/BerkeleyDB.18.1/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing DB utilities: /usr/local/BerkeleyDB.18.1/bin ...
libtool: install: cp -p .libs/db_archive /usr/local/BerkeleyDB.18.1/bin/db_archive
libtool: install: cp -p .libs/db_checkpoint /usr/local/BerkeleyDB.18.1/bin/db_checkpoint
libtool: install: cp -p .libs/db_convert /usr/local/BerkeleyDB.18.1/bin/db_convert
libtool: install: cp -p .libs/db_deadlock /usr/local/BerkeleyDB.18.1/bin/db_deadlock
libtool: install: cp -p .libs/db_dump /usr/local/BerkeleyDB.18.1/bin/db_dump
libtool: install: cp -p .libs/db_hotbackup /usr/local/BerkeleyDB.18.1/bin/db_hotbackup
libtool: install: cp -p .libs/db_load /usr/local/BerkeleyDB.18.1/bin/db_load
libtool: install: cp -p .libs/db_log_verify /usr/local/BerkeleyDB.18.1/bin/db_log_verify
libtool: install: cp -p .libs/db_printlog /usr/local/BerkeleyDB.18.1/bin/db_printlog
libtool: install: cp -p .libs/db_recover /usr/local/BerkeleyDB.18.1/bin/db_recover
libtool: install: cp -p .libs/db_replicate /usr/local/BerkeleyDB.18.1/bin/db_replicate
libtool: install: cp -p .libs/db_stat /usr/local/BerkeleyDB.18.1/bin/db_stat
libtool: install: cp -p .libs/db_tuner /usr/local/BerkeleyDB.18.1/bin/db_tuner
libtool: install: cp -p .libs/db_upgrade /usr/local/BerkeleyDB.18.1/bin/db_upgrade
libtool: install: cp -p .libs/db_verify /usr/local/BerkeleyDB.18.1/bin/db_verify
Installing documentation: /usr/local/BerkeleyDB.18.1/docs ...
cp: cannot stat 'bdb-sql': No such file or directory
cp: cannot stat 'gsg_db_server': No such file or directory
Makefile:1307: recipe for target 'install_docs' failed
make: *** [install_docs] Error 1
I am quite confused of why it is prompting this error, as bdb-sql and gsg_db_server is not something that is mentioned in the installation manual.
Does anyone know how these errors can be fixed?
Thanks for help!

As #fuzzyTew said, this appears to be a bug with 18.1.40, but as it's limited to the documentation it should be safe enough to patch yourself. There's two simple ways to do this. By far the easier is to just create the directories it wants in the docs directory, easily accomplished with mkdir db-18.1.40/docs/bdb-sql db-18.1.40/docs/gsg_db_server. This will leave you with a random pair of empty directories in your documentation folder, but I can't find any references even within the documentation itself that uses them so it should be safe enough. Alternatively, you can remove them from the Makefile after running configure using sed -i.bak -e 's: bdb-sql : :' -e 's: gsg_db_server : :' Makefile. Personally, I prefer just making the empty directories as it's nearly impossible for that to go wrong.

Based on the other answers, I found that the best solution for me was to copy the missing directories from 18.1.32 into my 18.1.40 source:
tar -xzvf db-18.1.32.tar.gz
tar -xzvf db-18.1.40.tar.gz
cp -rp db-18.1.32/docs/bdb-sql db-18.1.40/docs/
cp -rp db-18.1.32/docs/gsg_db_server db-18.1.40/docs/
This way you get the best of both worlds... you don't have to downgrade to 32, and you get the docs instead of empty doc folders. Obviously, these docs are for the previous version and might not be 100% correct, but IMO they are better than nothing.

This appears to be a bug with libdb 18.1.40 and should be reported to Oracle. Version 18.1.32 is at https://download.oracle.com/otn/berkeley-db/db-18.1.32.tar.gz

Related

Set env variable for HSL so IPOPT can use the solver `ma57`

I am sorry but I am not good at setting environment variables / manual builds. I have downloaded the HSL solvers for IPOPT and I believe that I successfully install the whole package but I cannot set the environment variables so I can use it from IPOPT. I am getting this error message:
Exception message: Selected linear solver MA57 not available.
Tried to obtain MA57 from shared library "libhsl.so", but the following error occured:
libhsl.so: cannot open shared object file: No such file or directory
I went according this advice https://stackoverflow.com/a/67655434/12312879 but I am not sure what to do next. The last command sudo make install printed this:
libtool: install: /usr/bin/install -c .libs/libcoinhsl.so.2.2.1 /usr/local/lib/libcoinhsl.so.2.2.1
libtool: install: (cd /usr/local/lib && { ln -s -f libcoinhsl.so.2.2.1 libcoinhsl.so.2 || { rm -f libcoinhsl.so.2 && ln -s libcoinhsl.so.2.2.1 libcoinhsl.so.2; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libcoinhsl.so.2.2.1 libcoinhsl.so || { rm -f libcoinhsl.so && ln -s libcoinhsl.so.2.2.1 libcoinhsl.so; }; })
libtool: install: /usr/bin/install -c .libs/libcoinhsl.lai /usr/local/lib/libcoinhsl.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
If you have a current (3.14) Ipopt, then try setting Ipopt option hsllib to /usr/local/lib/libcoinhsl.so.
If Ipopt is older, then it doesn't have the hsllib option. You can try copying your libcoinhsl.so.2.2.1 to libhsl.so and ensure that Ipopt finds it (e.g., by having its path in LD_LIBRARY_PATH).
I you build Ipopt from source, then the preferred way would be to provide HSL at buildtime, see also https://coin-or.github.io/Ipopt/INSTALL.html#DOWNLOAD_HSL.

Tp-Link T2600G-28TS GPL Source Code Compiling Error

i am trying to build t2600g-28ts switch's u-boot and buildroot linux
to get bootloader for modifying device my next goal is flashing OpenWRT.
It is a bcm53547 based board
I have tried build instructions below and no lucks.
I think may toolchains are the problem so how can i solve the problem .
any help would be appreciated thanks..
T2600-28TS GPL Codes
https://static.tp-link.com/resources/gpl/t2600g-28ts_gpl_20181206.tar.gz
Build Instructions
1. All build targets are in "t2600g-28ts_gpl/tplink/buildroot-wolfhound2/" and "t2600g-28ts_gpl/ldk/XLDK_4.2.1/bootloader/uboot-2016.01", you should enter the directory to build components.
2. Toolchain binary is avaliable in this package. The directory is "t2600g-28ts_gpl/tplink/buildroot-wolfhound2/host/usr/bin/".
3. Building steps:
1) put t2600g-28ts_gpl in directory /project/trunk
2) export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/project/trunk/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/host/usr/lib"
3) cd /project/trunk/t2600g-28ts_gpl/tplink/buildroot-wolfhound2
3) make O=./build/t2600g-28ts tplink-t2600g-28ts_defconfig
4) make O=./build/t2600g-28ts
After step4 completed, The linux kernel image, rootfs filesystem will be found in directory "t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/images".
5) cd /project/trunk/t2600g-28ts_gpl/ldk/XLDK_4.2.1/bootloader/uboot-2016.01
6) export CROSS_COMPILE=/project/trunk/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/host/usr/bin/arm-linux-
7) export ARCH=arm
8) export PATH="$PATH:/project/trunk/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/host/usr/bin"
9) make O=./build-output bcm953547k_defconfig
10) make O=./build-output all
After step11 completed, uboot will be found in directory "t2600g-28ts_gpl/ldk/XLDK_4.2.1/bootloader/uboot-2016.01".
My work
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:~/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/host/usr/lib"
cd ~/t2600g-28ts_gpl/tplink/buildroot-wolfhound2
make O=./build/t2600g-28ts tplink-t2600g-28ts_defconfig
Build Debugs
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/bin
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/sbin
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/bin
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/sbin
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/lib
ln -snf lib /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/lib32
ln -snf lib /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib32
>>> skeleton undefined Fixing libtool files
>>> skeleton undefined Installing to target
rsync -a --ignore-times --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' board/broadcom/iproc/skeleton/ /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/target/
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/target/bin
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/target/sbin
/usr/bin/install -d -m 0755 /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/target/lib
ln -snf lib /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/target/lib32
ln -snf lib /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/target/usr/lib32
/usr/bin/install -m 0644 support/misc/target-dir-warning.txt /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
>>> toolchain-external undefined Extracting
>>> toolchain-external undefined Patching
>>> toolchain-external undefined Configuring
Cannot execute cross-compiler '/home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/host/usr/bin/arm-linux-gcc.br_real'
make[1]: *** [package/pkg-generic.mk:189: /home/topcu/t2600g-28ts_gpl/tplink/buildroot-wolfhound2/build/t2600g-28ts/build/toolchain-external-undefined/.stamp_configured] Error 1
make: *** [Makefile:36: _all] Error 2
I have the same problem. I managed to solve it by compiling on CentOS 6.10, but I had to install GCC and some python dependencies first. Now I'm trying to upload as image in EVE-NG

Error Loading Shared Library (glew)

I compiled the library GLEW. It seemed to work fine, here is the output of make install:
install -d -m 0755 "/usr/include/GL"
install -m 0644 include/GL/wglew.h "/usr/include/GL/"
install -m 0644 include/GL/glew.h "/usr/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/include/GL/"
sed \
-e "s|#prefix#|/usr|g" \
-e "s|#libdir#|/usr/lib64|g" \
-e "s|#exec_prefix#|/usr/bin|g" \
-e "s|#includedir#|/usr/include/GL|g" \
-e "s|#version#|1.11.0|g" \
-e "s|#cflags#||g" \
-e "s|#libname#|GLEW|g" \
-e "s|#requireslib#|glu|g" \
< glew.pc.in > glew.pc
install -d -m 0755 "/usr/lib64"
install -m 0644 lib/libGLEW.so.1.11.0 "/usr/lib64/"
ln -sf libGLEW.so.1.11.0 "/usr/lib64/libGLEW.so.1.11"
ln -sf libGLEW.so.1.11.0 "/usr/lib64/libGLEW.so"
install -m 0644 lib/libGLEW.a "/usr/lib64/"
install -d -m 0755 "/usr/lib64"
install -d -m 0755 "/usr/lib64/pkgconfig"
install -m 0644 glew.pc "/usr/lib64/pkgconfig/"
Now I wanted to use it on a KDevelop project. I created my CMakeLists.txt and linked the library there using find_package:
cmake_minimum_required( VERSION 2.6 )
project(openglengine)
include_directories(headers)
set(SOURCE_FILES src/main.cpp)
set(CMAKE_CXX_FLAGS "--pedantic-errors -Wall -std=gnu++11")
add_executable(openglengine ${SOURCE_FILES} ${HEADER_FILES})
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
include_directories(${GLFW_INCLUDE_DIRS})
target_link_libraries(openglengine ${GLFW_STATIC_LIBRARIES})
find_package(GLEW)
if (GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
target_link_libraries (openglengine ${GLEW_LIBRARIES})
endif (GLEW_FOUND)
install(TARGETS openglengine RUNTIME DESTINATION ~/projects/OpenGLEngine/bin)
I get no build errors.
When I try to run the program here is the output:
error while loading shared libraries: libGLEW.so.1.11: cannot open shared object file: No such file or directory
Any help will be appreciated.
EDIT:
Using the command locate libGLEW I get this output:
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libGLEW.so.1.10.0
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libGLEW.so.1.6
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libGLEW.so.1.6.0
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libGLEW.so.1.10
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libGLEW.so.1.10.0
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libGLEW.so.1.6
/home/lhahn/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libGLEW.so.1.6.0
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEW.a
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEW.so
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEW.so.1.11
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEW.so.1.11.0
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEWmx.a
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEWmx.so
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEWmx.so.1.11
/home/lhahn/.local/share/Trash/files/glew/lib/libGLEWmx.so.1.11.0
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEW.a
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEW.so
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEW.so.1.11
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEW.so.1.11.0
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEWmx.a
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEWmx.so
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEWmx.so.1.11
/home/lhahn/Documents/OpenGL-Utils/GLEW/glew-1.11.0/lib/libGLEWmx.so.1.11.0
/usr/lib64/libGLEW.a
/usr/lib64/libGLEW.so
/usr/lib64/libGLEW.so.1.11
/usr/lib64/libGLEW.so.1.11.0
Which show that I have the library. Does that mean that the command find_package may be not working? Which is strange because I get no link errors.
So, I managed to make it work by creating a symbolic link in /usr/lib/ for the library that was in /usr/lib64.
sudo ln -s /usr/lib64/libGLEW.so.1.11 /usr/lib/libGLEW.so.1.11
Now it works fine. Since I am no expert on linux I don't know if that will bring me problems in the future.
I don't know if the answer by #Ihahn will have any issues but, if the some program is not finding your shared libraries, then first find the folder that your library was installed and is not in your shared library folder and then run sudo ldconfig <location_where_your_library_or_program_was_installed>. Sometimes this happens when you're installing/building programs via make install.Reference here..

/usr/lib/libpthread.so: No such file or directory && /usr/lib/libm.so: No such file or directory Solutioned

Solutioned with sudo ln -s /usr/lib64/libm.so /lib and ln -s /usr/lib64/libpthread.so /lib
libm.so is in this directory: /usr/lib64/libm.so
libpthread is in this dir : /usr/lib64/libpthread.so
I tried ln -s /usr/lib/libthread.so /lib64/libpthread.so and the same error appears, Does the machine needs a reboot?
I am having problems making the client OPENDMTP in C with Centos 6.3
my source files: https://sourceforge.net/projects/opendmtp/files/client-c/1.2.3/
I installed : yum groupinstall "Development Tools"
I tried to install the needed libraries but they are already installed.
Trying : "make dest=linux dmtp" I get the next :
[root#localhost OpenDMTP_client-c_1.2.0]# make dest=linux dmtp
Make tools dirs ...
/bin/mkdir -p ./build_lin/obj
/bin/mkdir -p ./build_lin/obj/tools
/bin/mkdir -p ./build_lin/obj/lib
Make './build_lin/obj/lib/libtools.a' ...
ar rc ./build_lin/obj/lib/libtools.a ./build_lin/obj/tools/checksum.o ./build_lin/obj/tools/base64.o ./build_lin/obj/tools/bintools.o ./build_lin/obj/tools/buffer.o ./build_lin/obj/tools/gpstools.o ./build_lin/obj/tools/strtools.o ./build_lin/obj/tools/utctools.o ./build_lin/obj/tools/threads.o ./build_lin/obj/tools/sockets.o ./build_lin/obj/tools/io.o ./build_lin/obj/tools/comport.o ./build_lin/obj/tools/random.o
ranlib ./build_lin/obj/lib/libtools.a
Make module dirs ...
/bin/mkdir -p ./build_lin/obj
/bin/mkdir -p ./build_lin/obj/modules
/bin/mkdir -p ./build_lin/obj/lib
Make './build_lin/obj/lib/libmodule.a' ...
ar rc ./build_lin/obj/lib/libmodule.a ./build_lin/obj/modules/odometer.o ./build_lin/obj/modules/motion.o ./build_lin/obj/modules/geozone.o
ranlib ./build_lin/obj/lib/libmodule.a
Make base dirs ...
/bin/mkdir -p ./build_lin/obj
/bin/mkdir -p ./build_lin/obj/base
/bin/mkdir -p ./build_lin/obj/lib
Make './build_lin/obj/lib/libbase.a' ...
ar rc ./build_lin/obj/lib/libbase.a ./build_lin/obj/base/mainloop.o ./build_lin/obj/base/propman.o ./build_lin/obj/base/event.o ./build_lin/obj/base/events.o ./build_lin/obj/base/packet.o ./build_lin/obj/base/pqueue.o ./build_lin/obj/base/protocol.o ./build_lin/obj/base/accting.o ./build_lin/obj/base/upload.o
ranlib ./build_lin/obj/lib/libbase.a
make dest=linux XPORT_MEDIA=-DTRANSPORT_MEDIA_SOCKET -f src/custom/custom.mk dmtpd_all
make[1]: Entering directory `/home/centos/Downloads/OpenDMTP_client-c_1.2.0'
Making sample DMTP reference implementation ...
Make dmtp object dirs ...
/bin/mkdir -p ./build_lin/obj/custom
/bin/mkdir -p ./build_lin/obj/custom/linux
/bin/mkdir -p ./build_lin/obj/custom/modules
/bin/mkdir -p ./build_lin/obj/dmtp
Linking 'dmtpd' ...
cc -o ./build_lin/obj/dmtp/dmtpd -Wall -DTARGET_LINUX -DTRANSPORT_MEDIA_SOCKET -DPROTOCOL_THREAD -DGPS_THREAD -Isrc /usr/lib/libpthread.so /usr/lib/libm.so ./build_lin/obj/custom/startup.o ./build_lin/obj/custom/transport.o ./build_lin/obj/custom/log.o ./build_lin/obj/custom/gps.o ./build_lin/obj/custom/gpsmods.o ./build_lin/obj/custom/linux/os.o -L./build_lin/obj/lib -lmodule -lbase -ltools
cc: /usr/lib/libpthread.so: No such file or directory
cc: /usr/lib/libm.so: No such file or directory
make[1]: *** [dmtpd_exe] Error 1
make[1]: Leaving directory `/home/centos/Downloads/OpenDMTP_client-c_1.2.0'
make: *** [dmtp_socket] Error 2
From the archive you link to I see in /OpenDMTP_client-c_1.2.3/make/common.mk at line 54:
SOLIBS = $(LINUX_LIBS)/libpthread.so $(LINUX_LIBS)/libm.so
This is an odd way of giving these libraries on linux and is not likely to work. They are special system libraries and do not live in such predictable locations. The normal way to specify them is with -lm and -pthread (without the l).
As a quick hack editing /OpenDMTP_client-c_1.2.3/make/common.mk hack and replacing line 54 with:
SOLIBS =
and modifying line 82 to be:
ALIBS = -L$(LIB_DIR) -lmodule -lbase -ltools -lm -pthread
Should solve the problem. Though I'm not sure of the effect on the other platforms.

Makefile: Check write permission to directory

Is there a way to, in a Makefile rule, check if it has permission to write to a specified directory? This is a small part of the Makefile I'm writing:
APP_NAME = electro
CC = gcc
C_FLAGS = -Wall
LIB_DIR = lib
SRC_DIR = src
INST_DIR = /usr/bin
INST_LIBDIR = /usr/lib
LIBS = libcomponent.so libpower.so libresistance.so
L_FLAGS = -lresistance -lpower -lcomponent
.PHONY: lib
lib:
#$(MAKE) --directory=$(LIB_DIR)
install: $(SRC_DIR)/main.c lib
(cd $(LIB_DIR); cp $(LIBS) $(INST_LIBDIR))
$(CC) $(C_FLAGS) -o $(INST_DIR)/$(APP_NAME) $(L_FLAGS) $<
#echo "$(APP_NAME) installed successfully."
The 'install' rule will obviously fail if the user doesn't have permission to write to /usr/lib and /usr/bin. Is there a way to check this permission before executing these two lines and in that case output an appropriate error message (perhaps something along the lines of "You do not have sufficient permissions to run this command")?
Shell's /bin/test or /bin/[ will let you /bin/test -d /path/to/foo -a -w /path/to/foo, even if make doesn't by itself.
An alternate way to make a directory accessible is to try to create it with mkdir -p before testing whether it's writable. I've been known to do the following:
mkdir -p ${TARGETDIR} && test -w ${TARGETDIR}
If the first command fails, the second isn't tried. If the directory already exists, mkdir -p will succeed.
You do things like that more or less by embedding small bits of shell scripts into your makefile.

Resources