We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

How to setup/install including mosquitto header/library file in ubuntu18.04?



    • current progress status :
    1. I got set up cross-compiling by referring to the onion site(https://docs.onion.io/omega2-docs/cross-compiling.html).
    2. and compiled the test c code and checked that the code is implemented.
    • my question is :
    1. I want to compile the mosquitto code in C language.
    2. but, I don't know way to include the mosquitto.h file and library.
    3. how to set up or install the mosquitto header file and library in ubuntu 18.04?
    4. What should I install or set up in Ubuntu to compile mosquitto code?

    cross compile environment : ubuntu 18.04
    using device : omega2

    If anyone knows how to do it, please let me know.
    thanks.



  • @jongrock-chun Are you trying to modify the mosquitto code?



  • @crispyoz thanks for the reply.
    I had an error that : mosquitto.h: No such file or directory.
    so I think, I need to install the compiling package of mosquitto for omega2.
    I don't understand, what's mean 'modify the mosquitto code'?



  • add :
    The main question is, did anyone succeed in compiling the mosquitto code into the c language for omega2?
    I want to compile the mosquitto code in c language for omega2.
    thanks.



  • @jongrock-chun I am trying to understand what you are trying to achieve, if you only want to use mosquitto on the Omega2+ you can simply install the application.

    opkg install mosquitto-ssl

    or

    opkg install mosquitto-nossl



  • @crispyoz thanks for the reply.
    I understood your intention of the previous reply.
    I would like to handle the command according to the receiving messages I received.
    so I would like to compile it in c language and put it in omega2.
    (like esp32/8266 mqtt communication way)
    thanks.



  • @jongrock-chun OK so if I understand you correctly, you want to make a C program that can subscribe to a particular topic and then handle that message. Correct?

    Do you have the build system installed? The headers and libraries required for this are part of the build system and you need to ensure you have installed the mosquitto-dev components. Then take a look at how to use NetBeans to compile apps for Omega2+, even if you don't want to use NetBeans you can see which paths you need to include in your make files so the headers and libs can be found.

    https://community.onion.io/topic/4131/setup-netbeans-11-for-c-c-development-cross-compilation



  • @crispyoz thanks for the reply.
    yes, I want to make a C program that can publish/subscribe to topics.

    I had build system installed on ubuntu18.04(ubuntu).
    and I succeeded in printing 'hello world' on omega2.

    I installed the package of mosquitto and libmosquitto-dev on ubuntu.
    (apt-get install mosquitto libmosquitto-dev)

    mosquitto version : 2.0.14
    mosquitto command list : mosquitto, mosquitto_pub(sub), mosquitto_passwd etc.

    so I have found the mosquitto.h in '/usr/include/mosquitto.h'
    but, there isn't mosquitto.h file in the folder related to 'mipsel-openwrt-linux'.
    (ex, /home/source/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/gcc-7.3.0/../../include/mosquitto.h)
    if I want to complie the c code with mosquitto function, mosquitto.h file have to be in the folder related 'mipsel-openwrt-linux'? is it right?

    or is it possible, I can compile the c code with mosquitto using '/usr/include/mosquitto.h'?

    if there is anything I misunderstood, please let me know.

    I'm going to review the site you linked.
    once again, thank you for your answer.



  • @jongrock-chun OK so now I understand what you would like to achieve.

    If you are using apt-get this will install header to develop an app to run on Ubuntu. If you wish to develop app to run on Omega2+ / OpenWrt then you need to ensure you have installed the required headers/libs etc on the build system.

    From Ubuntu command prompt,

    cd /home/source
    make menuconfig

    From the menu select "Libraries"
    Scroll down to find "libmosquitto" (-ssl or -nossl)

    Once this is completed run make, this will download the required files and if you refer to my NetBeans article you can see where the required header/libs will be located



  • @crispyoz Thank you for your consideration.
    I'd like to install the libmosquitto. but, there is not libmosquitto in Libraries tap.
    so, I checked the feeds.conf file in the /source folder for verifying OpenWrt version.

    list of feeds.conf file

    src-git packages https://git.openwrt.org/feed/packages.git;openwrt-18.06
    src-git luci https://git.openwrt.org/project/luci.git;openwrt-18.06
    src-git routing https://git.openwrt.org/feed/routing.git;openwrt-18.06
    src-git telephony https://git.openwrt.org/feed/telephony.git;openwrt-18.06
    src-git onion https://github.com/OnionIoT/OpenWRT-Packages.git;openwrt-18.06

    contents of build_info.json

    version: 0.3.3
    build: 251

    Can I get the new version of build system?
    or should I install the mosquitto package manually?

    thanks.



  • @jongrock-chun Try running these commands:

    switch to the openwrt branch

    git checkout openwrt-18.06

    sudo apt install ncurses-dev
    sudo apt install gawk

    clean out any old LEDE related feeds

    ./scripts/feeds clean
    ./scripts/feeds update -a
    ./scripts/feeds install -a

    sh scripts/onion-feed-setup.sh
    python scripts/onion-setup-build.py



  • @crispyoz thanks for your reply again.
    I got a late answer because this community site went down.

    As a result of the above method you told me, I finally found the libmosquitto in menu>libraries.
    thanks again.
    but, I had an error during making the build system.

    error : recipe for target 'world' failed

    so, I'm trying to run the command('make j1 V=s') to see the exact error.
    if I succeed with the simple mqtt code, I'll post it to you.



  • @jongrock-chun make sure you have run the command:

    scripts/onion-minimal-build.sh

    This makes the build much faster.

    If you have the error post the part of the log



  • @crispyoz First of all, I would like to express my deep gratitude for your interest.
    I am even more grateful for your sincere help with my poor English skills.

    I found the reason for the error.
    Linux for cross-compile was executed on a virtual environment in Windows. (like VMware s/w)
    However, an error occurred due to the lack of size given to Linux.

    It was found that size of at least 30G or more was required when the installation was performed in the above way.

    I succeeded to execute the simple mqtt code.

    Once again, I want to say thank you so much.

    I hope this article helps others when they have similar problems.

    So I want to modify the title of this article to more appropriate,
    so please advise if there is a title to recommend.

    Thanks to you, I am so grateful to solve this problem.



  • @jongrock-chun Thanks for the update, we are happy you were able to solve the problem. The fun part will now begin if you want to publish/subscribe using SSL/TLS. But that is a different topic. I keep meaning to post a tutorial but haven't had time yet.



  • @crispyoz thanks for your advice.
    Do you know anything about sites or codes to refer to for SSL?
    if you know that, let me know.



  • @jongrock-chun create a new topic for this question and I will reply there. Easier for other users to find later.



  • @crispyoz OK, I got it.
    I'll proceed it.



  • I also followed the guidance on this thread, and successfully created a mosquitto client in our pre-existing C++ application. Thank you very much for both the questions and the answers. I cannot express how useful this thread has been to me. Very unlikely I would have ever succeeded on my own.


Log in to reply
 

Looks like your connection to Community was lost, please wait while we try to reconnect.