-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSVC + vcpkg: Exception thrown. g was nullptr. #315
Comments
Same/Similar; first call works (ImGui::SFML::Update()), second call (any ImGui::Begin()) its effectively nullptr. |
If I add |
Could you elaborate? Did you add imgui-SFML.cpp and correspondingly remove the imgui-SFML Vcpkg package? |
Edited: He Isn't wrong.., I have the source unpacked in a new folder in my vcpkg folder, so I just #include'd the .cpp file to my main.cpp (C:\vcpkg\source\imgui-sfml\imgui-SFML.cpp) (in my test app), removing the #include "imgui-SFML.h" that I had instead. changed nothing of my vcpkg configuration, and it works, trying my main program... Edit(new): Working. |
What I have observed is as follows.
cmake_minimum_required(VERSION 3.26)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
# imgui sfml example
project(ex CXX)
set(CMAKE_CXX_STANDARD 23)
find_package(imgui CONFIG REQUIRED)
find_package(ImGui-SFML CONFIG REQUIRED)
find_package(SFML COMPONENTS Graphics CONFIG REQUIRED)
add_executable(${PROJECT_NAME} main.cpp imgui-SFML.cpp)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
ImGui-SFML::ImGui-SFML
)
|
FYI, another vcpkg issue on Windows was resolved so you should update vcpkg first.
|
I took a closer look at that and it motivated #316 but it doesn't seem related to this issue. |
So it's safe to say this error necessarily requires using DLLs? I wonder if it's something incorrect about how we're handling global state. I know that when switching from static libs to dynamic libs problems like this can arise if you're not careful. I wonder if the same problem exists other OSes when using dynamic libs. |
My observation is end user's perspective. vcpkg uses shared libs on Windows and static libs on Linux by default. I tested with the example code (https://github.com/SFML/imgui-sfml/tree/master/examples) using the latest version of libs. So, I don't understand "...problems like this can arise if you're not careful...". My question is that why this happens when I updated libs to the latest version. |
My comment wasn’t super clear. The “you” I’m referring to are the library maintainers such as myself who are putting globals in libraries. We have to be careful. Are you able to test with shared libs on Linux to see if the problem also exists with that config? |
The code runs using shared libs on Linux. I followed instructions from this (microsoft/vcpkg#24048 (comment)) and tested on Fedora.
|
Hi, the following code used to work using SFML 2.6 but an exception was thrown after updating to v3.0.
The text was updated successfully, but these errors were encountered: