I use SFML 2.3.1 builded from the git repo.
And I am running on Yosemite 10.10.4.
And I am running on Yosemite 10.10.4.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
target_link_libraries(brain
sfml-system
sfml-window
sfml-graphics)
/usr/local/lib/libtgui.so: undefined reference to `sf::String::substring(unsigned int, unsigned int) const'
/usr/local/lib/libtgui.so: undefined reference to `sf::Image::~Image()'
collect2: error: ld returned 1 exit status
$ make
[ 2%] Building CXX object src/TGUI/CMakeFiles/tgui.dir/Widget.cpp.o
/libs/tgui/src/TGUI/Widget.cpp:451:16: error: chosen constructor is
explicit in copy-initialization
return {};
^~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/map:838:14: note:
constructor declared here
explicit map(const key_compare& __comp = key_compare())
^
1 error generated.
make[2]: *** [src/TGUI/CMakeFiles/tgui.dir/Widget.cpp.o] Error 1
make[1]: *** [src/TGUI/CMakeFiles/tgui.dir/all] Error 2
make: *** [all] Error 2
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
cmake_minimum_required(VERSION 2.6)
project(Brain C CXX)
# Fichier de sortie
set(EXECUTABLE_OUTPUT_PATH build/${CMAKE_BUILD_TYPE})
set(LIBRARY_OUTPUT_PATH lib/${CMAKE_BUILD_TYPE})
# Compiling in C++11. Settings compiler flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -g")
# Detect Libs
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake/Modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2 REQUIRED system window graphics)
if(NOT SFML_FOUND)
message(FATAL_ERROR "Could not find SFML")
endif()
add_subdirectory(Brain)
set(SOURCES
main.cpp
)
add_executable(brain ${SOURCES})
target_link_libraries(brain
${SFML_LIBRARIES}
)
#ifndef GUI_HPP
#define GUI_HPP
#include <TGUI/TGUI.hpp>
#include "manage_state.hpp"
class SystemGui
{
public:
SystemGui(ManageState &manage_state);
void loadWidgets(tgui::Gui& gui);
private:
void linkStartButton(tgui::Button::Ptr button);
ManageState &_manage_state;
};
#endif // GUI_HPP
//////////////////////////////////////////////////
#include "gui.hpp"
SystemGui::SystemGui(ManageState &manage_state) :
_manage_state{manage_state}
{}
void SystemGui::loadWidgets( tgui::Gui& gui )
{
// Create the login button
tgui::Button::Ptr startbutton(gui);
startbutton->load("./widgets/Black.conf");
startbutton->setSize(260, 60);
startbutton->setPosition(270, 300);
startbutton->setText("Start");
startbutton->bindCallback(std::bind(linkStartButton, startbutton), tgui::Button::LeftMouseClicked);
startbutton->bindCallback(tgui::Button::LeftMouseClicked);
startbutton->setCallbackId(1);
}
void SystemGui::linkStartButton(tgui::Button::Ptr button)
{
_manage_state.updateStart();
if (button->getText() == "Start")
{
button->setText("Stop");
} else {
button->setText("Start");
}
}
error: reference to non-static member function must
be called
startbutton->bindCallback(std::bind(linkStartButton, startbutton), tgui::Button::LeftMous...
Failed to create window
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 3 (X_GetWindowAttributes)
Resource id in failed request: 0x140000d
Serial number of failed request: 65
Current serial number in output stream: 66
startbutton->bindCallback(std::bind(func, startbutton), tgui::Button::LeftMouseClicked);
tgui::Callback callback;
while (_gui.pollCallback(callback))
{
if (callback.id == 1)
{
cout<<"hello"<<endl;
}
}
tgui::Callback callback;
while (_gui.pollCallback(callback))
{
if (callback.id == 1)
{
_gui.get("startbutton")->setText("Stop");
}
}
// Create the login button
tgui::Button::Ptr startbutton(gui, "startbutton");
startbutton->load("./widgets/Black.conf");
startbutton->setSize(260, 60);
startbutton->setPosition(270, 300);
startbutton->setText("Start");
startbutton->bindCallback(tgui::Button::LeftMouseClicked);
startbutton->setCallbackId(1);