Skip to content

Commit dc2fe54

Browse files
Merge branch 'linux-flutter-build' into 'main'
Fix Flutter Linux apps missing C library Closes #46 See merge request objectbox/objectbox-dart!30
2 parents 7ccc9d9 + 356d878 commit dc2fe54

File tree

5 files changed

+110
-35
lines changed

5 files changed

+110
-35
lines changed

flutter_libs/linux/CMakeLists.txt

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
1-
cmake_minimum_required(VERSION 3.11)
1+
# The Flutter tooling requires that developers have CMake 3.10 or later
2+
# installed. You should not increase this version, as doing so will cause
3+
# the plugin to fail to compile for some customers of the plugin.
4+
cmake_minimum_required(VERSION 3.10)
5+
6+
# Project-level configuration.
27
set(PROJECT_NAME "objectbox_flutter_libs")
38
project(${PROJECT_NAME} LANGUAGES CXX)
49

510
# This value is used when generating builds using this plugin, so it must
6-
# not be changed
11+
# not be changed.
712
set(PLUGIN_NAME "objectbox_flutter_libs_plugin")
813

14+
# Define the plugin library target. Its name must not be changed (see comment
15+
# on PLUGIN_NAME above).
16+
#
17+
# Any new source files that you add to the plugin should be added here.
918
add_library(${PLUGIN_NAME} SHARED
1019
"objectbox_flutter_libs_plugin.cc"
1120
)
21+
22+
# Apply a standard set of build settings that are configured in the
23+
# application-level CMakeLists.txt. This can be removed for plugins that want
24+
# full control over build settings.
1225
apply_standard_settings(${PLUGIN_NAME})
26+
27+
# Symbols are hidden by default to reduce the chance of accidental conflicts
28+
# between plugins. This should not be removed; any symbols that should be
29+
# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
1330
set_target_properties(${PLUGIN_NAME} PROPERTIES
1431
CXX_VISIBILITY_PRESET hidden)
1532
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
33+
34+
# Source include directories and library dependencies. Add any plugin-specific
35+
# dependencies here.
1636
target_include_directories(${PLUGIN_NAME} INTERFACE
1737
"${CMAKE_CURRENT_SOURCE_DIR}/include")
1838
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
1939
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
2040

21-
# List of absolute paths to libraries that should be bundled with the plugin
22-
set(objectbox_flutter_libs_bundled_libraries
23-
""
24-
PARENT_SCOPE
25-
)
26-
2741
# ----------------------------------------------------------------------
42+
# Download and add objectbox-c prebuilt library.
2843

2944
set(OBJECTBOX_VERSION 0.18.0)
3045

@@ -48,15 +63,15 @@ if(NOT objectbox-download_POPULATED)
4863
FetchContent_Populate(objectbox-download)
4964
endif()
5065

66+
# ----------------------------------------------------------------------
67+
68+
# List of absolute paths to libraries that should be bundled with the plugin.
69+
# This list could contain prebuilt libraries, or libraries created by an
70+
# external build triggered from this build file.
71+
72+
# Note: do not link the ObjectBox C library; the Dart library looks for it in a lib subfolder
73+
# where flutter build puts it when added below.
5174
set(objectbox_flutter_libs_bundled_libraries
5275
"${objectbox-download_SOURCE_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}objectbox${CMAKE_SHARED_LIBRARY_SUFFIX}"
5376
PARENT_SCOPE
5477
)
55-
56-
add_library(objectbox SHARED IMPORTED GLOBAL)
57-
set_target_properties(objectbox PROPERTIES
58-
IMPORTED_LOCATION ${objectbox-download_SOURCE_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}objectbox${CMAKE_SHARED_LIBRARY_SUFFIX}
59-
IMPORTED_IMPLIB ${objectbox-download_SOURCE_DIR}/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}objectbox${CMAKE_IMPORT_LIBRARY_SUFFIX}
60-
)
61-
62-
target_link_libraries(${PLUGIN_NAME} PRIVATE objectbox)

flutter_libs/windows/CMakeLists.txt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
1-
cmake_minimum_required(VERSION 3.15)
1+
# The Flutter tooling requires that developers have a version of Visual Studio
2+
# installed that includes CMake 3.14 or later. You should not increase this
3+
# version, as doing so will cause the plugin to fail to compile for some
4+
# customers of the plugin.
5+
cmake_minimum_required(VERSION 3.14)
6+
7+
# Project-level configuration.
28
set(PROJECT_NAME "objectbox_flutter_libs")
39
project(${PROJECT_NAME} LANGUAGES CXX)
410

511
# This value is used when generating builds using this plugin, so it must
612
# not be changed
713
set(PLUGIN_NAME "objectbox_flutter_libs_plugin")
814

15+
# Define the plugin library target. Its name must not be changed (see comment
16+
# on PLUGIN_NAME above).
917
add_library(${PLUGIN_NAME} SHARED
1018
"objectbox_flutter_libs_plugin.cpp"
1119
)
20+
21+
# Apply a standard set of build settings that are configured in the
22+
# application-level CMakeLists.txt. This can be removed for plugins that want
23+
# full control over build settings.
1224
apply_standard_settings(${PLUGIN_NAME})
25+
26+
# Symbols are hidden by default to reduce the chance of accidental conflicts
27+
# between plugins. This should not be removed; any symbols that should be
28+
# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
1329
set_target_properties(${PLUGIN_NAME} PROPERTIES
1430
CXX_VISIBILITY_PRESET hidden)
1531
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
32+
33+
# Source include directories and library dependencies. Add any plugin-specific
34+
# dependencies here.
1635
target_include_directories(${PLUGIN_NAME} INTERFACE
1736
"${CMAKE_CURRENT_SOURCE_DIR}/include")
1837
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
1938

20-
# List of absolute paths to libraries that should be bundled with the plugin
39+
# List of absolute paths to libraries that should be bundled with the plugin.
40+
# This list could contain prebuilt libraries, or libraries created by an
41+
# external build triggered from this build file.
2142
set(objectbox_flutter_libs_bundled_libraries
2243
""
2344
PARENT_SCOPE
2445
)
2546

2647
# ----------------------------------------------------------------------
48+
# Download and add objectbox-c prebuilt library.
2749

2850
set(OBJECTBOX_VERSION 0.18.0)
2951

objectbox/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## latest
22

3+
* Flutter Linux apps do not longer fail to run due to the shared ObjectBox C library not loading. #504
34

45
## 1.7.1 (2023-01-17)
56

sync_flutter_libs/linux/CMakeLists.txt

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
1+
# The Flutter tooling requires that developers have CMake 3.10 or later
2+
# installed. You should not increase this version, as doing so will cause
3+
# the plugin to fail to compile for some customers of the plugin.
14
cmake_minimum_required(VERSION 3.10)
5+
6+
# Project-level configuration.
27
set(PROJECT_NAME "objectbox_sync_flutter_libs")
38
project(${PROJECT_NAME} LANGUAGES CXX)
49

510
# This value is used when generating builds using this plugin, so it must
6-
# not be changed
11+
# not be changed.
712
set(PLUGIN_NAME "objectbox_sync_flutter_libs_plugin")
813

14+
# Define the plugin library target. Its name must not be changed (see comment
15+
# on PLUGIN_NAME above).
16+
#
17+
# Any new source files that you add to the plugin should be added here.
918
add_library(${PLUGIN_NAME} SHARED
1019
"objectbox_sync_flutter_libs_plugin.cc"
1120
)
21+
22+
# Apply a standard set of build settings that are configured in the
23+
# application-level CMakeLists.txt. This can be removed for plugins that want
24+
# full control over build settings.
1225
apply_standard_settings(${PLUGIN_NAME})
26+
27+
# Symbols are hidden by default to reduce the chance of accidental conflicts
28+
# between plugins. This should not be removed; any symbols that should be
29+
# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
1330
set_target_properties(${PLUGIN_NAME} PROPERTIES
1431
CXX_VISIBILITY_PRESET hidden)
1532
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
33+
34+
# Source include directories and library dependencies. Add any plugin-specific
35+
# dependencies here.
1636
target_include_directories(${PLUGIN_NAME} INTERFACE
1737
"${CMAKE_CURRENT_SOURCE_DIR}/include")
1838
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
1939
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
2040

21-
# List of absolute paths to libraries that should be bundled with the plugin
22-
set(objectbox_sync_flutter_libs_bundled_libraries
23-
""
24-
PARENT_SCOPE
25-
)
26-
2741
# ----------------------------------------------------------------------
42+
# Download and add objectbox-c prebuilt library.
2843

2944
set(OBJECTBOX_VERSION 0.18.0)
3045

@@ -48,15 +63,15 @@ if(NOT objectbox-download_POPULATED)
4863
FetchContent_Populate(objectbox-download)
4964
endif()
5065

66+
# ----------------------------------------------------------------------
67+
68+
# List of absolute paths to libraries that should be bundled with the plugin.
69+
# This list could contain prebuilt libraries, or libraries created by an
70+
# external build triggered from this build file.
71+
72+
# Note: do not link the ObjectBox C library; the Dart library looks for it in a lib subfolder
73+
# where flutter build puts it when added below.
5174
set(objectbox_sync_flutter_libs_bundled_libraries
5275
"${objectbox-download_SOURCE_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}objectbox${CMAKE_SHARED_LIBRARY_SUFFIX}"
5376
PARENT_SCOPE
5477
)
55-
56-
add_library(objectbox SHARED IMPORTED GLOBAL)
57-
set_target_properties(objectbox PROPERTIES
58-
IMPORTED_LOCATION ${objectbox-download_SOURCE_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}objectbox${CMAKE_SHARED_LIBRARY_SUFFIX}
59-
IMPORTED_IMPLIB ${objectbox-download_SOURCE_DIR}/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}objectbox${CMAKE_IMPORT_LIBRARY_SUFFIX}
60-
)
61-
62-
target_link_libraries(${PLUGIN_NAME} PRIVATE objectbox)

sync_flutter_libs/windows/CMakeLists.txt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
1-
cmake_minimum_required(VERSION 3.15)
1+
# The Flutter tooling requires that developers have a version of Visual Studio
2+
# installed that includes CMake 3.14 or later. You should not increase this
3+
# version, as doing so will cause the plugin to fail to compile for some
4+
# customers of the plugin.
5+
cmake_minimum_required(VERSION 3.14)
6+
7+
# Project-level configuration.
28
set(PROJECT_NAME "objectbox_sync_flutter_libs")
39
project(${PROJECT_NAME} LANGUAGES CXX)
410

511
# This value is used when generating builds using this plugin, so it must
612
# not be changed
713
set(PLUGIN_NAME "objectbox_sync_flutter_libs_plugin")
814

15+
# Define the plugin library target. Its name must not be changed (see comment
16+
# on PLUGIN_NAME above).
917
add_library(${PLUGIN_NAME} SHARED
1018
"objectbox_sync_flutter_libs_plugin.cpp"
1119
)
20+
21+
# Apply a standard set of build settings that are configured in the
22+
# application-level CMakeLists.txt. This can be removed for plugins that want
23+
# full control over build settings.
1224
apply_standard_settings(${PLUGIN_NAME})
25+
26+
# Symbols are hidden by default to reduce the chance of accidental conflicts
27+
# between plugins. This should not be removed; any symbols that should be
28+
# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
1329
set_target_properties(${PLUGIN_NAME} PROPERTIES
1430
CXX_VISIBILITY_PRESET hidden)
1531
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
32+
33+
# Source include directories and library dependencies. Add any plugin-specific
34+
# dependencies here.
1635
target_include_directories(${PLUGIN_NAME} INTERFACE
1736
"${CMAKE_CURRENT_SOURCE_DIR}/include")
1837
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
1938

20-
# List of absolute paths to libraries that should be bundled with the plugin
39+
# List of absolute paths to libraries that should be bundled with the plugin.
40+
# This list could contain prebuilt libraries, or libraries created by an
41+
# external build triggered from this build file.
2142
set(objectbox_sync_flutter_libs_bundled_libraries
2243
""
2344
PARENT_SCOPE
2445
)
2546

2647
# ----------------------------------------------------------------------
48+
# Download and add objectbox-c prebuilt library.
2749

2850
set(OBJECTBOX_VERSION 0.18.0)
2951

0 commit comments

Comments
 (0)