thezbyg / gpick

Advanced color picker written in C++ using GTK+ toolkit
BSD 3-Clause "New" or "Revised" License
376 stars 33 forks source link

gpick v0.3 compil fail on Archlinux #211

Closed PowaBanga closed 2 years ago

PowaBanga commented 2 years ago

Hi everybody, gpick crash on start on my archlinux :

/usr/include/c++/12.1.0/bits/basic_string.h:1280: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::front() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&]: Assertion '!empty()' failed.
[1]    5307 IOT instruction (core dumped)  gpick

does anybody know why ?

PowaBanga commented 2 years ago

ok on archlinux, gpick is actualy on v0.2.6. Compil of the v0.3 fail... after read this https://github.com/thezbyg/gpick/issues/209#issuecomment-1204551008 i created my own PKGBUILD on the V0.3 release with my diff to patch in, and it worked !

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb6c670..5141263 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,8 +30,8 @@ if (PkgConfig_FOUND)
        pkg_check_modules(GTK2 gtk+-2.0>=2.24)
        pkg_check_modules(GioUnix gio-unix-2.0>=2.24)
    endif()
-   pkg_search_module(Lua lua5.4-c++>=5.4 lua5-c++>=5.4 lua5.3-c++>=5.3 lua5-c++>=5.3 lua-c++>=5.3 lua5.2-c++>=5.2 lua-c++>=5.2)
-   pkg_check_modules(Expat expat>=1.0)
+   pkg_search_module(Lua lua5.4>=5.4 lua5>=5.4 lua5.3>=5.3 lua5>=5.3 lua>=5.3 lua5.2>=5.2 lua>=5.2)
+    pkg_check_modules(Expat expat>=1.0)
 endif()
 set(THREADS_PREFER_PTHREAD_FLAG ON)
 find_package(Threads REQUIRED)
diff --git a/source/ColorSpaceType.cpp b/source/ColorSpaceType.cpp
index 8f5d124..a1c0c22 100644
--- a/source/ColorSpaceType.cpp
+++ b/source/ColorSpaceType.cpp
@@ -22,7 +22,9 @@
 #include "lua/Color.h"
 #include "lua/Script.h"
 #include "lua/Callbacks.h"
+extern "C" {
 #include <lua.h>
+}
 #include <iostream>
 using namespace std;

diff --git a/source/Converter.cpp b/source/Converter.cpp
index ee9d7d7..9e82b34 100644
--- a/source/Converter.cpp
+++ b/source/Converter.cpp
@@ -33,8 +33,10 @@
 #include <vector>
 #include <iostream>
 #include <functional>
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 using namespace std;
 Converter::Converter(const char *name, const char *label, lua::Ref &&serialize, lua::Ref &&deserialize):
    m_name(name),
diff --git a/source/GlobalState.cpp b/source/GlobalState.cpp
index ca6542b..c848141 100644
--- a/source/GlobalState.cpp
+++ b/source/GlobalState.cpp
@@ -37,8 +37,10 @@
 #include <filesystem>
 #include <stdlib.h>
 #include <glib/gstdio.h>
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 #include <fstream>
 #include <iostream>
 struct GlobalState::Impl {
diff --git a/source/layout/Layout.cpp b/source/layout/Layout.cpp
index c81a927..6ba7bf9 100644
--- a/source/layout/Layout.cpp
+++ b/source/layout/Layout.cpp
@@ -20,8 +20,10 @@
 #include "System.h"
 #include "../lua/Layout.h"
 #include <iostream>
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 using namespace std;
 namespace layout
 {
diff --git a/source/lua/Color.cpp b/source/lua/Color.cpp
index 724831a..47d6bf4 100644
--- a/source/lua/Color.cpp
+++ b/source/lua/Color.cpp
@@ -18,8 +18,10 @@

 #include "Color.h"
 #include "../Color.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 namespace lua
 {
 static int newColor(lua_State *L)
diff --git a/source/lua/ColorObject.cpp b/source/lua/ColorObject.cpp
index a1971b5..19f15e6 100644
--- a/source/lua/ColorObject.cpp
+++ b/source/lua/ColorObject.cpp
@@ -20,8 +20,10 @@
 #include "Color.h"
 #include "Script.h"
 #include "../ColorObject.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 namespace lua
 {
 static int newColorObject(lua_State *L)
diff --git a/source/lua/DynvSystem.cpp b/source/lua/DynvSystem.cpp
index ff3508c..dfbba25 100644
--- a/source/lua/DynvSystem.cpp
+++ b/source/lua/DynvSystem.cpp
@@ -17,8 +17,10 @@
  */

 #include "DynvSystem.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 namespace lua {
 dynv::Ref checkDynvSystem(lua_State *L, int index) {
    void *ud = luaL_checkudata(L, index, "dynvSystem");
diff --git a/source/lua/Extensions.cpp b/source/lua/Extensions.cpp
index 62c6c1b..6e14e84 100644
--- a/source/lua/Extensions.cpp
+++ b/source/lua/Extensions.cpp
@@ -31,8 +31,10 @@
 #include "../Converters.h"
 #include "../Converter.h"
 #include "version/Version.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 namespace lua
 {
 static void checkArgumentIsFunctionOrNil(lua_State *L, int index)
diff --git a/source/lua/GlobalState.cpp b/source/lua/GlobalState.cpp
index 8908538..984bb91 100644
--- a/source/lua/GlobalState.cpp
+++ b/source/lua/GlobalState.cpp
@@ -18,8 +18,10 @@

 #include "GlobalState.h"
 #include "../GlobalState.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 namespace lua
 {
 void setGlobalState(lua_State *L, GlobalState &global_state)
diff --git a/source/lua/I18N.cpp b/source/lua/I18N.cpp
index 6791c97..f7fd0e6 100644
--- a/source/lua/I18N.cpp
+++ b/source/lua/I18N.cpp
@@ -18,8 +18,10 @@

 #include "I18N.h"
 #include "../I18N.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 namespace lua
 {
 int getText(lua_State *L)
diff --git a/source/lua/Layout.cpp b/source/lua/Layout.cpp
index be83686..b2dfd2b 100644
--- a/source/lua/Layout.cpp
+++ b/source/lua/Layout.cpp
@@ -23,8 +23,10 @@
 #include "../layout/Box.h"
 #include "../layout/System.h"
 #include "../layout/Layout.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 #include <typeinfo>
 #include <iostream>
 using namespace std;
diff --git a/source/lua/Ref.cpp b/source/lua/Ref.cpp
index 9b1acc7..96c108f 100644
--- a/source/lua/Ref.cpp
+++ b/source/lua/Ref.cpp
@@ -17,8 +17,10 @@
  */

 #include "Ref.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 namespace lua
 {
 Ref::Ref():
diff --git a/source/lua/Script.cpp b/source/lua/Script.cpp
index a39e3eb..6358327 100644
--- a/source/lua/Script.cpp
+++ b/source/lua/Script.cpp
@@ -18,8 +18,10 @@

 #include "Script.h"
 #include <sstream>
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 #include <iostream>
 using namespace std;
 namespace lua
diff --git a/source/test/Script.cpp b/source/test/Script.cpp
index 8fdeaa9..55a6c3e 100644
--- a/source/test/Script.cpp
+++ b/source/test/Script.cpp
@@ -19,8 +19,10 @@
 #include <boost/test/unit_test.hpp>
 #include "lua/Script.h"
 #include "common/Scoped.h"
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 using namespace lua;
 static int test(lua_State *L) {
    lua_pushstring(L, "ok");
diff --git a/source/uiDialogOptions.cpp b/source/uiDialogOptions.cpp
index e70debb..b072944 100644
--- a/source/uiDialogOptions.cpp
+++ b/source/uiDialogOptions.cpp
@@ -28,8 +28,10 @@
 #include "lua/Callbacks.h"
 #include <string>
 #include <iostream>
+extern "C" {
 #include <lualib.h>
 #include <lauxlib.h>
+}
 using namespace std;
 static const struct{
    const char *label;