Build Paho MQTT-SN gateway in MSYS2 - cmake

I am facing what I think is a configuration issue. I would like to build Paho MQTTSN gateway in Msys2 to make it run on Windows. What I do is :
I clone the repository, and I put it in /c/msys64/home/ folder
I add /c/msys64/mingw64/bin to $PATH because cmake cannot locate gcc otherwise.
I run ./build.sh udp command. Here is the output :
$ ./build.sh udp
Start building MQTT-SN Gateway udp
-- CMake version: 3.23.2
-- CMake system name: Windows
-- Timestamp is 2022-09-06T11:17:49Z
-- VERSION : 1.5.1
-- SENSORNET: udp
-- Definitions:
-- Configuring done
-- Generating done
-- Build files have been written to: C:/msys64/home/paho.mqtt-sn
make: *** No rule to make target 'MQTTSNPacket'. Stop.
make: *** No rule to make target 'MQTT-SNGateway'. Stop.
make: *** No rule to make target 'MQTT-SNLogmonitor'. Stop.
I tried to play around with cmake -G. I tried "MSYS Makefiles", but didn't had any chances.
I am still a bit confused with cmake, does someone have an idea?
By the way, paho is building fine on Ubuntu.
Thank you very much for your help

Related

How to compile ClickHouse in CLion?

I'm trying to build ClickHouse in CLion.
I follow the official documentation. I was able to build ClickHouse from the command line, however, I would also like to be able to build it in CLion.
The documentation doesn't give out much information on how to do that, only implies that it's possible. ClickHouse's GitHub Issues search by 'CLion' also do not offer much advice.
ClickHouse uses CMake and Ninja. The documentation mentions that one can use either Ninja or make instead of Ninja to compile in CLion.
I tried both and got many errors. For example, when running with CMake settings set to -G Ninja, I was able to build the target common but I get the following error when building the target clickhouse-client:
====================[ Build | clickhouse-client | Debug ]=======================
/usr/bin/cmake --build /tmp/tmp.CAA3nJhi8z/cmake-build-debug --target clickhouse-client
[1/7338] Generating lber-version.c
FAILED: contrib/openldap-cmake/lber-version.c
cd /tmp/tmp.CAA3nJhi8z/contrib/openldap && /usr/bin/cmake -E env bash -c "/tmp/tmp.CAA3nJhi8z/contrib/openldap/build/mkversion -v '2.5.X' liblber.la > \"/tmp/tmp.CAA3nJhi8z/cmake-build-debug/contrib/openldap-cmake/lber-version.c\""
bash: /tmp/tmp.CAA3nJhi8z/contrib/openldap/build/mkversion: Permission denied
[18/7338] Building CXX object contrib/..._/icu/icu4c/source/i18n/calendar.cpp.o
ninja: build stopped: subcommand failed.
I also use a remote toolchain in CLion to build on a server, not my laptop. Since it's a permission issue, I assume I have to run the build from sudo but I'm not sure how to do that, and searching only offers a guide on How to debug as root in CLion.
Question #2. Is it OK that after CMake loaded in CLion, I don't see any green arrows in the CMakeLists.txt in the root of the ClickHouse project? I can only see targets in the top right corner dropdown (screenshot).
Question #3. I'm also unsure how to build all the binaries in CLion. E.g. in the command line, I would just run ninja but in CLion there are so many targets, and none of them is named like build all.
Any pointers to a solution are much appreciated.
It might be helpful to someone to answer your first question.
Since you are using a remote build, the Clion first copies all source files to the remote machine. And if the option
Settings -> Build,Execution,Deployment -> Deployment -> Options -> Preserve original file permissions
is not enabled, it does not save the executable permissions to run some scripts. Which breaks the build.
Therefore, you can either enable this option and re-upload the files or set permission x manually to the files that will be logged in the error message.

Issues using cmake on cygwin

I have a project which was previously linux only in makefile.
I have successfully migrated it to cmake and that works fine, it compiles in pure linux (makefile --> so) and pure windows (visual studio --> dll) with no issue. It also compiles fine on linux for windows (using mingw --> dll).
However, for integration and script compatibility issues, I have to generate and build the code for windows (dll) but on a cygwin environment (with cygwin's gcc providing a dll), like the old makefile used to do.
(I have to do this way, due to external constraints)
I have installed both "make" and "cmake" packages on my cygwin.
When I try to generate a makefile in the cygwin console, it gets stuck:
$ cmake -G "Unix Makefiles" ../Sources
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
[ -- stuck - nothing happens here -- ]
When I stop it (ctrl-C), it says nothing and the "Makefile" file is present in my build directory, so I try and compile it:
$ make
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
[ -- stuck - nothing happens here -- ]
It seems to be re-generating all all over again (I get my cmake prints again, the Makefile file disappears then reappears and the command gets stuck at the same stage again).
This time, when I stop it, it prints the following message:
$ make
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
make: *** [Makefile:224: cmake_check_build_system] Interrupt
I've tried to look up the Makefile and it seems to be the following command that blocks:
cmake_check_build_system:
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check- build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
I searched and found this thread, so it seems to just be a way to set the directories.
I've tried running it manually and the result is the same:
$ cmake -H../Sources -B. --check-build-system CMakeFiles/Makefile.cmake 0
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
[ -- stuck - nothing happens here -- ]
I don't know what I'm doing wrong and I'm stuck, could someone help me?
Edit: running make in verbose mode gives a little more information:
$ make VERBOSE=1
/usr/bin/cmake.exe -H/cygdrive/e/Projects/MyProject/Sources -B/cygdrive/e/Projects/MyProject/Build_Cygwin --check-build-system CMakeFiles/Makefile.cmake 0
Re-run cmake: build system dependency is missing
[ -- misc CMake prints from my CMakeLists.txt -- ]
-- Configuring done
As suggested by Fred, I used --trace to get more info --> there was absolutely nothing after Configuring done.
Then, as suggested by Tsyvarev, I simplified the CMakeLists to the bare minimum, where it was ok. Then I added things bit by bit until I identified the issue.
It came from cmake path variables that contained drive letters (like "E:/...") that made cmake go nuts and get stuck.
I made a small macro to patch all path variable, replacing drive letters by "/cygdrive/[drive letter]/..." and after patching them all, everything went back to normal. For those interested:
macro(PatchPath PATHTOPATCH OUTPUT_VAR)
if(${TARGET_SYSTEM_TYPE} MATCHES "cygwin")
string(SUBSTRING ${PATHTOPATCH} 0 1 CYG_DRIVE)
string(TOLOWER ${CYG_DRIVE} CYG_DRIVE)
string(SUBSTRING ${PATHTOPATCH} 2 -1 TMP_END_OF_PATH)
set(${OUTPUT_VAR} "/cygdrive/${CYG_DRIVE}${TMP_END_OF_PATH}")
endif()
endmacro()
Thanks everyone!

mono build on cygwin have error ,how to do build?

I do it according to the instructions by (http://www.mono-project.com/docs/compiling-mono/windows/)
PATH=$PREFIX/bin:$PATH
git clone https://github.com/mono/mono.git
cd mono
do shell cmd ./autogen.sh --prefix=$PREFIX --host=x86_64-w64-mingw32 --disable-boehm
Git submodules updated successfully
mcs source: mcs
C# Compiler: roslyn
Engine:
Host: x86_64-w64-mingw32
Target: x86_64-w64-mingw32
GC: sgen (concurrent by default)
TLS: pthread
SIGALT STACK: no
Engine: Building and using the JIT
BigArrays: no
DTrace: no
LLVM Back End: no (dynamically loaded: no)
Libraries:
.NET 4.x: yes
Xamarin.Android: no
Xamarin.iOS: no
Xamarin.WatchOS: no
Xamarin.TVOS: no
Xamarin.Mac: no
Windows AOT: no
Orbis: no
Unreal: no
WebAssembly: no
Test profiles: AOT Full (no), AOT Hybrid (no)
JNI support: no
libgdiplus: assumed to be installed
zlib:
BTLS: no
jemalloc: no (always use: no)
Now type `make' to compile
do make and then have below error
C:/cygwin64/home/Administrator/mono/mono/mini/mono-sgen.exe:
error while loading shared libraries: ?: cannot open shared object file: No such file or directory
make[8]: *** [il.make:4:../../../class/lib/basic/corlib.unsafe.dll.tmp] 错误 127
make[7]: *** [../../../build/rules.make:211:do-all] 错误 2
make[6]: *** [../build/rules.make:232:all-recursive] 错误 1
make[5]: *** [build/rules.make:232:all-recursive] 错误 1
make[4]: *** [Makefile:54:profile-do--basic--all] 错误 2
make[3]: *** [Makefile:50:profiles-do--all] 错误 2
make[2]: *** [Makefile:613:all-local] 错误 2
make[2]: 离开目录“/home/Administrator/mono/runtime”
make[1]: *** [Makefile:558:all-recursive] 错误 1
make[1]: 离开目录“/home/Administrator/mono”
make: *** [Makefile:488:all] 错误 2
I have hit this myself twice, but... you aren't supposed to run that thing, actually. You use msbuild to build mono.exe and run make to build the BCL.
The problem you are seeing, is that, in following the directions, you have cross built a mingw mono.exe from a cygwin host. I know, they seem like the same thing, but they aren't quite. The mingw mono.exe fails to run in cygwin environment because it doesn't find libgcc_s.dll or so, and maybe others.
If you dir /s/b C:\cygwin64\libgcc*.dll and notice the mingw sysroot, you can add that directory or directories to your %PATH%, and then this mingw mono.exe will work. However, the right solution is probably a proper mingw install, not using the sysroot, and again, this mono.exe isn't the goal.
Once you use msbuild, you get native Visual C++, and its symbols, and its debugger or windbg, and therein to me is one of the huge values of windows -- the debuggers -- which cygwin and mingw don't give you.
Try to execute C:/cygwin64/home/Administrator/mono/mono/mini/mono-sgen.exe directly - it should complain it misses some cygwin files - copy them to this folder
It doesn't work because the mingw .dlls aren't in $PATH.
You have cross-build a mingw mono from Cygwin environment.
I strongly recommend though you use msbuild against the msvc/*.sln file instead, using Visual C++ instead of mingw to build, and thereby the Visual Studio and windbg debuggers work.

building a out-of-tree module on Beagle Bone Black

Machine Details :
Linux beaglebone 3.8.13-bone47 armv7l GNU/Linux
Problem Details:
In a attempt to write out-of-tree modules on beagle bone black(as intree modules require me to compile/flash them again and again ), i have logged in to beagle bone black revc through ssh client, which gives me a command line interface via putty, as in general out-of-tree module development, i have tried to compile module with the following make file
ifneq ($(KERNELRELEASE),)
# kbuild part of makefile
obj-m := module.o
#module-objs := module.o
else
# normal makefile
KDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
endif
resulting an error
root#beaglebone:~/lddgeek# make
make -C /lib/modules/3.8.13-bone47/build M=/root/lddgeek modules
make: *** /lib/modules/3.8.13-bone47/build: No such file or directory. Stop.
make: *** [default] Error 2
but when i parse to the path of KDIR i did not find build folder as we find it in an normal ubuntu installed on x86
if i have to develop drivers/modules out-of-tree on a Beagle how could i do that?
The reason i was not able to compile was i was missing the kbuild environment , i need to install kernel headers which will give me the capability to compile out-of-tree/external modules
#wget https://raw.github.com/gkaindl/beaglebone-ubuntu-scripts/master/bb-get-rcn-kernel-source.sh
#chmod +x bb-get-rcn-kernel-source.sh
#./bb-get-rcn-kernel-source.sh
The above steps actually helped me in solving the errors faced , while i was able to insert,remove the hello world module that i was trying to build

CMake | Why Doesn't Start?

I have checked out the project on two different platforms and they give me -
on Ubuntu (have installed cmake and ccmake)
$ make
cd .build && make --no-print-directory
make[1]: *** No targets specified and no makefile found. Stop.
make: *** [all] Error 2
on Mac OS X (it starts off ...)
$ make
touch .configured
cd .build && cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
It seems like Ubuntu is still trying to compile using make?
cmake is a generator for build-system control files. It does not drive the build by itself, but is relies on external tools like make, nmake or some GUIs to build the software. The cd .build && cmake .. line in the osx build only updates the build system files, the build itself is driven by make there.
The error on the ubunto box probably is that there is no Makefile in .build, which means that cmake wasn't executed there, or it failed there previously. You can run cmake by hand with cd .build && cmake ...
If there's a configure script in the project, can you try:
./configure
make