douwefokkema / AutoTrackRaymarine_pi

Follow a route on OpenCPN using a Raymarine Evolution pilot
GNU General Public License v3.0
14 stars 6 forks source link

How to build locally in Linux?? Does not work on RPI #38

Closed rgleason closed 1 year ago

rgleason commented 1 year ago

Douwe wrote: "I need to do some debugging on Linux, it seems that the plugin does not work on Rpi. So to be sure that all is in line, I made a fresh clone from my (newly merged) master.

But doing a cmake .. I get the following (can not find wxWidgets). Do you have clue? The error is at the end. OpenCPN compiles fine in the same environment."

douwe@douwe-AMD:~/AutoTrackRaymarine_pi/build$ cmake .. -- CMakeLists: USE_GL: ON -- CMakeLists: Build type: Release -- PluginSetup: GIT_REPOSITORY_SERVER not found setting to: github.com -- PluginSetup: PROJECT_VERSION: 1.18.31.0 -- PluginSetup: AutoTrackRaymarine Version: 1.18.31.0 -- PluginSetup: OPCN_FLATPAK: -- PluginSetup: OCPN_FLATPAK_CONFIG: , OCPN_FLATPAK_BUILD: , UNIX: 1 -- PluginSetup: Will install to /usr/local -- PluginSetup: Debian detected -- PluginSetup: ARCH: x86_64 -- PluginSetup: PKG_TARGET: ubuntu, PKG_TARGET_VERSION: 22.04 -- PluginSetup: OCPN_TARGET: -- PluginSetup: PKG_TARGET: ubuntu -- PluginSetup: CMAKE version: 3.22.1 -- PluginSetup: Setting RPATH: $ORIGIN:$ORIGIN/.. -- PluginConfigure: Staging to build AutoTrackRaymarine_pi -- PluginConfigure: CIRCLECI: , Env CIRCLECI: -- PluginConfigure: TRAVIS: , Env TRAVIS: -- PluginConfigure: GIT_REPOSITORY_REMOTE: origin -- PluginConfigure: START_URL: 19, STRING_LENGTH: 53 -- PluginConfigure: GIT_REPOSITORY: douwefokkema/AutoTrackRaymarine_pi -- PluginConfigure: Git Branch: "master" -- PluginConfigure: Git Tag: "" -- PluginConfigure: GIT_BRANCH_OR_TAG: branch -- PluginConfigure: GIT_REPOSITORY_ITEM: master -- PluginConfigure: CLOUDSMITH_BASE_REPOSITORY: autotrackraymarine -- PluginConfigure: PLUGIN_EXTRA_VERSION_VARS: Not Found -- PluginConfigure: PLUGIN_EXTRA_FORMBUILDER_HEADERS: PLUGIN_EXTRA_FORMBUILDER_HEADERS-NOTFOUND -- PluginConfigure: PLUGIN_EXTRA_FORMBUILDER_HEADERS: Not found -- PluginConfigure: ENV BUILD_GTK3: -- PluginConfigure: BUILD_ENV: , BUILD_ENV_TEMP , OCPN_TARGET: -- PluginConfigure: Doing build_gtk3: -- PluginConfigure: PKG_TARGET_GTK: -- PluginConfigure: ARCH: x86_64 -- PluginConfigure: Building against GTK2... -- PluginConfigure: PKG_NVR: AutoTrackRaymarine_pi-1.18.31.0, PKG_TARGET: ubuntu, ARCH: x86_64, PKG_TARGET_WX_VER: , PKG_BUILD_GTK: , PKG_TARGET_VERSION: 22.04, OCPN_TARGET: -- PluginConfigure: PACKAGING_NAME: AutoTrackRaymarine_pi-1.18.31.0-ubuntu-22.04 -- PluginConfigure: PACKAGING_NAME_XML: AutoTrackRaymarine_pi-1.18.31.0-ubuntu-x86_64-22.04 -- PluginConfigure: PKG_TARGET_FULL: ubuntu-x86_64 -- PluginConfigure: PKG_BUILD_TARGET: ubuntu -- PluginConfigure: PKG_BUILD_GTK: -- PluginConfigure: PKG_BUILT_WITH_GTK: gtk2 -- PluginConfigure: *.in files generated in /home/douwe/AutoTrackRaymarine_pi/build -- PluginConfigure: Build type: Release -- PluginConfigure: Optimisation: -O2 -s -- PluginConfigure: Finding package OpenGL -- PluginConfigure: Adding local GLU CMake Deprecation Warning at opencpn-libs/glu/CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.

Update the VERSION argument value or use a ... suffix to tell CMake that the project does not need compatibility with older versions.

CMake Warning (dev) at opencpn-libs/glu/CMakeLists.txt:10 (project): Policy CMP0048 is not set: project() command manages VERSION variables. Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH
PROJECT_VERSION_TWEAK

This warning is for project developers. Use -Wno-dev to suppress it.

-- CMakeLists_GLU: CMAKE_CURRENT_SOURCE_DIR: /home/douwe/AutoTrackRaymarine_pi/opencpn-libs/glu, CMAKE_SOURCE_DIR: /home/douwe/AutoTrackRaymarine_pi -- CMakeLists_GLU: include dir='/home/douwe/AutoTrackRaymarine_pi/build/CMakeFiles/include' -- CMakeLists_GLU: include dir='/usr/include/freetype2' -- CMakeLists_GLU: include dir='/usr/include' -- CMakeLists_GLU: include dir='/usr/include/glib-2.0' -- CMakeLists_GLU: include dir='/usr/lib/x86_64-linux-gnu/glib-2.0/include' -- CMakeLists_GLU: include dir='/usr/include/atk-1.0' -- CMakeLists_GLU: include dir='/usr/include/gdk-pixbuf-2.0' -- CMakeLists_GLU: include dir='/usr/include/cairo' -- CMakeLists_GLU: include dir='/usr/include/harfbuzz' -- CMakeLists_GLU: include dir='/usr/include/pango-1.0' -- CMakeLists_GLU: include dir='/usr/include/gtk-2.0' -- CMakeLists_GLU: include dir='/usr/lib/x86_64-linux-gnu/gtk-2.0/include' -- CMakeLists_GLU: include dir='/home/douwe/AutoTrackRaymarine_pi/include' -- CMakeLists_GLU: include dir='/home/douwe/AutoTrackRaymarine_pi/src' -- CMakeLists_GLU: include dir='/home/douwe/AutoTrackRaymarine_pi/opencpn-libs/glu/include' -- PluginConfigure: PACKAGE_NAME: AutoTrackRaymarine_pi -- PluginConfigure: Revised GL Lib (with local): /usr/lib/x86_64-linux-gnu/libGL.so/usr/lib/x86_64-linux-gnu/libGLU.so -- PluginConfigure: wxWidgets_Version: -- PluginConfigure: wxWidgets components: base;core;net;xml;html;adv;aui;gl CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS) Call Stack (most recent call first): /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.22/Modules/FindwxWidgets.cmake:1025 (find_package_handle_standard_args) cmake/PluginConfigure.cmake:560 (find_package) CMakeLists.txt:134 (include)

-- Configuring incomplete, errors occurred!

rgleason commented 1 year ago

Sean has this question as well. He would like a simple way to build in linux / rpi and Android..

Perhaps the way I do it will give you a clue. To build locally in windows I use both the VS 2022 command prompt so that I can pipe the output to output.txt to debug stuff, and then after it is built I use the Bash promp to run the final script "bash ./cloudsmith-upload.sh"

Doing it this way does not require any env variables to be set.

My batch file bld.bat is as follows:

REM  Requires wxWidgets setup
REM  C:\Users\fcgle\source\wxWidgets-3.1.2
REM  C:\Users\fcgle\source\wxWidgets-3.2.2
REM  Visual Studio 15 2017  installed
REM  Visual Studio 17 2022  installed
REM --------------------------------------
REM  For Opencpn 5.8 and wxWidgets-3.2.2 using Visual Studio 15 2017 or 2022
REM --------------------------------------
REM Used for local builds and testing.
REM Create an empty "[plugin]/build" directory 
REM Use MSVC Command Prompt from [plugin]root directory   ".\bld.bat"
REM Find the errors in the build\output.txt file
REM Then use bash prompt to run cloudsmith-upload.sh command  "BASH ./bld.bat"
REM This adds the metadata file to the tarball gz file.
REM Set local environment using wxWidgets-3.2.2
set "wxDIR=%WXWIN%"
set "wxWidgets_ROOT_DIR=%WXWIN%"
set "wxWidgets_LIB_DIR=%WXWIN%\lib\vc14x_dll" 
set "WXWIN=C:\Users\fcgle\source\wxWidgets-3.2.2"
REM  For Opencpn 5.8 and wxWidgets-3.2.2
cd build
cmake -T v143 -A Win32 -DOCPN_TARGET=MSVC ..
cmake --build . --target package --config relwithdebinfo >output.txt
bash ./cloudsmith-upload.sh

REM --------------------------------------
REM  For Opencpn 5.6.2 and wxWidgets-3.1.2  release
REM --------------------------------------
REM  Using built C:\Users\fcgle\source\wxWidgets-3.1.2 and local settings
REM set "wxDIR=%WXWIN%"
REM set "wxWidgets_ROOT_DIR=%WXWIN%" 
REM set "wxWidgets_LIB_DIR=%WXWIN%\lib\vc14x_dll" 
REM set "WXWIN=C:\Users\fcgle\source\wxWidgets-3.1.2"
REM cd build
REM cmake -T v141_xp -DOCPN_TARGET=MSVC ..
REM cmake --build . --target package --config release >output.txt
REM bash ./cloudsmith-upload.sh

I am very interested in providing a Linux and android script for building these plugins locally and would put it in each plugin. Perhaps bdbcat can advise further.

Sean would like a simple way to build locally for Linux and Android. He also was confused about the "new" location for plugins and simply wanted the result to land there so he could easily test in Opencpn. I guess he is thinking about lib[plugin].so

Also I don't know about these

PROJECT_VERSION
PROJECT_VERSION_MAJOR
PROJECT_VERSION_MINOR
PROJECT_VERSION_PATCH
PROJECT_VERSION_TWEAK
rgleason commented 1 year ago

bdbcat wrote me back with this process. You should certainly make sure the submodule is loaded on your local version. If this helps and you can build, please let me know so that I can close this.

Linux & RPI

The trivial case for modern linux amd RPI plugins looks like this:

Make sure the submodule opencpn-libs is loaded

$git submodule update --init opencpn-libs

$mkdir build
$cd build
$cmake ..
$make
cp lib{whatever}_pi.so ~/.local/lib/opencpn

Start OCPN. The plugin will exist in the PIM list, as a pseudo-system plugin, as there is no metadata. But it can be enabled and tested like any other plugin. If the plugin requires private data, this will need to be copied manually.

rgleason commented 1 year ago

PS also note that for windows builds I first set the environment for wxwidgets in the batch file. Windows:

Use batch file "bld.bat". First use a VS 2022 Command Prompt to be able to review an output.txt file in the build directory. Then use a Bash prompt to run the script which copies the metadata into the tarball so that it is compatible with "Import Plugin"

set "wxDIR=%WXWIN%"
set "wxWidgets_ROOT_DIR=%WXWIN%"
set "wxWidgets_LIB_DIR=%WXWIN%\lib\vc14x_dll" 
set "WXWIN=C:\Users\fcgle\source\wxWidgets-3.2.2"
REM  For Opencpn 5.8 and wxWidgets-3.2.2
cd build
cmake -T v143 -A Win32 -DOCPN_TARGET=MSVC ..
cmake --build . --target package --config relwithdebinfo >output.txt
bash ./cloudsmith-upload.sh
rgleason commented 1 year ago

How to Set environment variables in linux https://linuxize.com/post/how-to-set-and-list-environment-variables-in-linux/#setting-environment-variables So you can do this in bash script file to set the wxWidgets variables locally

set "wxDIR=%WXWIN%"
set "wxWidgets_ROOT_DIR=%WXWIN%"
set "wxWidgets_LIB_DIR=%WXWIN%\lib\vc14x_dll" 
set "WXWIN=C:\Users\fcgle\source\wxWidgets-3.2.2"

Dave advises this should not be necessary in Linux

rgleason commented 1 year ago

Please refer to https://github.com/jongough/testplugin_pi/issues/348

bdbcat commented 1 year ago

Douwe... Regarding the build trouble: The basic problem here is that your system configuration contains GTK2, but does not contain wxWidgets built against GTK2. See the log:

-- PluginConfigure: Building against GTK2...

This is clearly a bug in the cmake file. The logic needs refactoring to search for GTK3, and associated wxWidgets, when this condition exists. I'll take that as a TODO. Meanwhile, you may work around by disabling the GTK2 check.

PluginConfigure.cmake:192

# find_package(GTK2)

Please confirm that this works, and I'll make the logic change. Dave

douwefokkema commented 1 year ago

Dave, you are great, compiles like a dream! @dwynalda reported #36, Linux only issue, n2k output from the plugin working fine, input towards the plugin fails. I am trying to sort this out, could be the plugin or O itself, not yet clear to me.

rgleason commented 1 year ago

I found this report from Lennart about building with ubuntu and gtk3 using cmake..

https://github.com/jongough/testplugin_pi/issues/294#issuecomment-1484119444

might be some help.

rgleason commented 1 year ago

@Bdbcat. Does this mean that none of the debian builds in circleci work or is the problem just limited to Douwe's local build env?

bdbcat commented 1 year ago

Rick... Specific to Douwe's system. CCI is fine.