First of all, I have to say that I'm only a beginner with c++ programming so it's the first time ever I try to set up sfml 2.4.0. I'm running Code::Blocks on Ubuntu 16.04 LTS. The script with the error is the same as the tutorial on SFML's official site:
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
using namespace std;
int main()
{
sf::RenderWindow finestra (sf::VideoMode(100,100), "Ciao!");
sf::CircleShape cerchio (100.f);
cerchio.setFillColor(sf::Color::Blue);
while (finestra.isOpen())
{
sf::Event evento;
while (finestra.pollEvent(evento))
{
if (evento.type == sf::Event::Closed)
finestra.close();
}
finestra.clear();
finestra.draw(cerchio);
finestra.display();
}
return 0;
}
Don't mind for strange names to variables and strings, I just wanted to get more familiar with the script using terms of my language.
The error appearing after I tried to build and run the script is this ("riferimento non definito a" means "undefined reference to"):
||=== Build: Debug in primo_game_magari_serio (compiler: GNU GCC Compiler) ===|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|106|riferimento non definito a "glClearColor"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|107|riferimento non definito a "glClear"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|276|riferimento non definito a "glVertexPointer"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|277|riferimento non definito a "glColorPointer"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|278|riferimento non definito a "glTexCoordPointer"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|287|riferimento non definito a "glDrawArrays"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|311|riferimento non definito a "glGetError"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|321|riferimento non definito a "glPushClientAttrib"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|322|riferimento non definito a "glPushAttrib"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|324|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|325|riferimento non definito a "glPushMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|326|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|327|riferimento non definito a "glPushMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|328|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|329|riferimento non definito a "glPushMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|341|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|342|riferimento non definito a "glPopMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|343|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|344|riferimento non definito a "glPopMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|345|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|346|riferimento non definito a "glPopMatrix"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|348|riferimento non definito a "glPopClientAttrib"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|349|riferimento non definito a "glPopAttrib"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|374|riferimento non definito a "glDisable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|375|riferimento non definito a "glDisable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|376|riferimento non definito a "glDisable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|377|riferimento non definito a "glDisable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|378|riferimento non definito a "glEnable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|379|riferimento non definito a "glEnable"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|380|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|381|riferimento non definito a "glEnableClientState"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|382|riferimento non definito a "glEnableClientState"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|383|riferimento non definito a "glEnableClientState"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|419|riferimento non definito a "glViewport"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|422|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|423|riferimento non definito a "glLoadMatrixf"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|426|riferimento non definito a "glMatrixMode"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|444|riferimento non definito a "glBlendFunc"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/RenderTarget.cpp|485|riferimento non definito a "glLoadMatrixf"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Shader.cpp|64|riferimento non definito a "glGetIntegerv"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Shader.cpp|984|riferimento non definito a "glFlush"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|66|riferimento non definito a "glGetIntegerv"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|72|riferimento non definito a "glGetIntegerv"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|124|riferimento non definito a "glDeleteTextures"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|166|riferimento non definito a "glGenTextures"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|214|riferimento non definito a "glBindTexture"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|215|riferimento non definito a "glTexImage2D"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|216|riferimento non definito a "glTexParameteri"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|217|riferimento non definito a "glTexParameteri"|
/usr/local/share/buildslave/tmp/build/src/SFML/Graphics/Texture.cpp|218|riferimento non definito a "glTexParameteri"|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
Here there are the project's build option (the ones I don't mention are set to default):
Search Directories/Compiler: /home/user/Downloads/SFML-2.4.0/include
Search Directories/Linker: /home/user/Downloads/SFML-2.4.0/lib (I also tried to add another "/include" but it didn't work too)
Linker Settings/Debug/sfml-graphics-s-d
sfml-window-s-d
sfml-system-s-d
Linker Settings/Release/sfml-graphics-s
sfml-window-s
sfml-system-s
Compiler Settings/#defines/SFML_STATIC
I searched for over a week in very single thread like these on the forum, but I never found the same problem as mine. If you need other information just ask, thank you in advance.
The undefined references are to opengl. You will need to add the opengl library.
In windows that would be opengl32, added after all the sfml libraries
In linux, I am not so certain, but it looks like GL
( It is strange that the SFML docs do not mention this. The windows version at https://www.sfml-dev.org/tutorials/2.4/start-cb.php does mention the dependency, but the screenshot does not show the library reference. The linux build instructions do not mention it at all! When you get this working, you should ask them to updated the docs. )
Related
i currently try to make JNI bindings for https://github.com/Mojang/leveldb-mcpe which can be found here https://github.com/GoMint/leveldbjni.
Compiling the project with the compile.sh in src/main/c/ hasn't been a problem under linux (ubuntu 18.04). The problem is that when i compile the same project with mingw64 in cygwin (g++) i get linker errors depending on which optimization level i choose.
The windows build script:
#!/bin/sh
CWD=$(pwd)
# First we start by this: you NEED cygwin with installed x86_64-w64-mingw32-g++ for this to work
CXX="x86_64-w64-mingw32-g++"
# We compile with c++0x because leveldb uses it as preferred language level
CXX="$CXX -std=c++0x"
# Some shared library switches
CXX="$CXX -s -shared -fPIC"
# This build should use the libc memcmp instead of the builtin one
CXX="$CXX -fno-builtin-memcmp"
# Since we use a "emulated" windows build chain we need to define that we are windows blue (10)
CXX="$CXX -D_WIN32_WINNT=0x0603"
# Now some leveldb config (telling we are windows and we want the mcpe windows hacks)
CXX="$CXX -DMCPE_PLATFORM_WINDOWS_FAMILY -DOS_WIN -DCYGWIN -DWIN32 -DNDEBUG -DDLLX="
# Some general improvements
CXX="$CXX -O2"
# Includes
CXX="$CXX -I$JAVA_HOME/include/ -I$JAVA_HOME/include/win32/ -I$CWD/leveldb-mcpe/ -I$CWD/leveldb-mcpe/include/ -v"
# We need the zlib.h in a seperate folder (because mojang added it to the wrong folder zlib/zlib.h where the normal import is simply zlib.h)
mkdir -p "$CWD/include/zlib/"
cp /usr/x86_64-w64-mingw32/sys-root/mingw/include/zlib.h "$CWD/include/zlib/zlib.h"
CXX="$CXX -I$CWD/include/"
# Verify that the built cmd is correct
echo $CXX
# Build the windows version
$CXX leveldb-mcpe/db/builder.cc leveldb-mcpe/db/c.cc\
leveldb-mcpe/db/db_impl.cc leveldb-mcpe/db/db_iter.cc\
leveldb-mcpe/db/dbformat.cc leveldb-mcpe/db/filename.cc\
leveldb-mcpe/db/log_reader.cc leveldb-mcpe/db/log_writer.cc\
leveldb-mcpe/db/memtable.cc leveldb-mcpe/db/repair.cc\
leveldb-mcpe/db/table_cache.cc leveldb-mcpe/db/version_edit.cc\
leveldb-mcpe/db/version_set.cc leveldb-mcpe/db/write_batch.cc\
leveldb-mcpe/db/snappy_compressor.cc\
leveldb-mcpe/db/zlib_compressor.cc\
leveldb-mcpe/db/zopfli_compressor.cc\
leveldb-mcpe/db/zstd_compressor.cc\
\
leveldb-mcpe/table/block.cc leveldb-mcpe/table/block_builder.cc\
leveldb-mcpe/table/filter_block.cc\
leveldb-mcpe/table/iterator.cc leveldb-mcpe/table/merger.cc\
leveldb-mcpe/table/table.cc leveldb-mcpe/table/table_builder.cc\
leveldb-mcpe/table/two_level_iterator.cc\
leveldb-mcpe/table/format.cc\
\
leveldb-mcpe/util/arena.cc leveldb-mcpe/util/bloom.cc\
leveldb-mcpe/util/cache.cc leveldb-mcpe/util/coding.cc\
leveldb-mcpe/util/comparator.cc leveldb-mcpe/util/crc32c.cc\
leveldb-mcpe/util/env.cc leveldb-mcpe/util/env_win.cc\
leveldb-mcpe/util/filter_policy.cc\
leveldb-mcpe/util/hash.cc\
leveldb-mcpe/util/histogram.cc leveldb-mcpe/util/logging.cc\
leveldb-mcpe/util/win_logger.cc leveldb-mcpe/util/options.cc\
leveldb-mcpe/util/status.cc\
\
leveldb-mcpe/port/port_win.cc leveldb-mcpe/port/port_posix_sse.cc\
\
io_gomint_leveldb_DB.cpp io_gomint_leveldb_Iterator.cpp io_gomint_leveldb_WriteBatch.cpp leveldbjni.cpp -o ../resources/leveldb-mcpe.dll -lz
Which compiles just fine but gives me this linker error:
/tmp/ccciWZjc.o:env_win.cc:(.text+0xe6f): Warnung: undefinierter Verweis auf »std::basic_filebuf<char, std::char_traits<char> >::_close()«
/tmp/ccciWZjc.o:env_win.cc:(.text+0x1a18): Warnung: undefinierter Verweis auf »std::basic_filebuf<char, std::char_traits<char> >::_close()«
/tmp/ccciWZjc.o:env_win.cc:(.text+0x1b7c): Warnung: undefinierter Verweis auf »std::basic_filebuf<char, std::char_traits<char> >::_close()«
/tmp/ccciWZjc.o:env_win.cc:(.text+0x1da8): Warnung: undefinierter Verweis auf »std::basic_filebuf<char, std::char_traits<char> >::_close()«
/tmp/ccciWZjc.o:env_win.cc:(.text+0x1f0c): Warnung: undefinierter Verweis auf »std::basic_filebuf<char, std::char_traits<char> >::_close()«
/tmp/ccciWZjc.o:env_win.cc:(.text+0x2124): Warnung: weitere undefinierte Verweise auf »std::basic_filebuf<char, std::char_traits<char> >::_close()« folgen
When i remove the optimization level the linker produces this error:
/tmp/ccD8ugVG.o:env_win.cc:(.text+0xa2c): Warnung: undefinierter Verweis auf »std::basic_ofstream<char, std::char_traits<char> >::_close()«
OSX 10.11.3 (El Capitan)
I'm getting link errors while building the first example from the Boost::Log tutorial.
#include <boost/log/trivial.hpp>
int main(int, char*[])
{
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
return 0;
}
Here are the diagnostics:
$ c++ trivial_log_test.cpp
Undefined symbols for architecture x86_64:
"boost::log::v2s_mt_posix::record_view::public_data::destroy(boost::log::v2s_mt_posix::record_view::public_data const*)", referenced from:
boost::log::v2s_mt_posix::record::reset() in trivial_log_test-6968b8.o
"boost::log::v2s_mt_posix::aux::stream_provider<char>::release_compound(boost::log::v2s_mt_posix::aux::stream_provider<char>::stream_compound*)", referenced from:
boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::auto_release::~auto_release() in trivial_log_test-6968b8.o
"boost::log::v2s_mt_posix::aux::stream_provider<char>::allocate_compound(boost::log::v2s_mt_posix::record&)", referenced from:
boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::record_pump(boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>&, boost::log::v2s_mt_posix::record&) in trivial_log_test-6968b8.o
"boost::log::v2s_mt_posix::aux::unhandled_exception_count()", referenced from:
boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::record_pump(boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>&, boost::log::v2s_mt_posix::record&) in trivial_log_test-6968b8.o
boost::log::v2s_mt_posix::aux::record_pump<boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level> >::~record_pump() in trivial_log_test-6968b8.o
"boost::log::v2s_mt_posix::core::open_record(boost::log::v2s_mt_posix::attribute_set const&)", referenced from:
boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex> >::open_record_unlocked<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> const&) in trivial_log_test-6968b8.o
"boost::log::v2s_mt_posix::core::push_record_move(boost::log::v2s_mt_posix::record&)", referenced from:
boost::log::v2s_mt_posix::sources::basic_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex> >::push_record_unlocked(boost::rv<boost::log::v2s_mt_posix::record>&) in trivial_log_test-6968b8.o
"boost::log::v2s_mt_posix::sources::aux::get_severity_level()", referenced from:
boost::log::v2s_mt_posix::sources::aux::severity_level<boost::log::v2s_mt_posix::trivial::severity_level>::set_value(boost::log::v2s_mt_posix::trivial::severity_level) in trivial_log_test-6968b8.o
"boost::log::v2s_mt_posix::trivial::logger::get()", referenced from:
_main in trivial_log_test-6968b8.o
"boost::log::v2s_mt_posix::core::get_logging_enabled() const", referenced from:
boost::log::v2s_mt_posix::record boost::log::v2s_mt_posix::sources::basic_composite_logger<char, boost::log::v2s_mt_posix::sources::severity_logger_mt<boost::log::v2s_mt_posix::trivial::severity_level>, boost::log::v2s_mt_posix::sources::multi_thread_model<boost::log::v2s_mt_posix::aux::light_rw_mutex>, boost::log::v2s_mt_posix::sources::features<boost::log::v2s_mt_posix::sources::severity<boost::log::v2s_mt_posix::trivial::severity_level>, void, void, void, void, void, void, void, void, void> >::open_record<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> >(boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::severity, boost::log::v2s_mt_posix::trivial::severity_level const> const&) in trivial_log_test-6968b8.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Several similar questions said that the following gave useful information:
$ clang++ -E -x c++ - -v < /dev/null
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.9 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/chap/private/cpp/BOOST_TESTING/log_test -ferror-limit 19 -fmessage-length 176 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o - -x c++ -
clang -cc1 version 7.0.2 based upon LLVM 3.7.0svn default target x86_64-apple-darwin15.3.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 332 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
Homebrew is installed and up-to-date. I reinstalled Boost:
$ brew reinstall boost
==> Reinstalling boost
==> Downloading https://homebrew.bintray.com/bottles/boost-1.60.0_1.el_capitan.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/boost-1.60.0_1.el_capitan.bottle.tar.gz
==> Pouring boost-1.60.0_1.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/boost/1.60.0_1: 11,139 files, 436.0M
In other similar questions about link errors using the Boost libraries, a common solution was to run bootstrap.sh to build the b2 executable to compile some libraries. However, these people installed Boost without using Homebrew. Homebrew's installation of Boost looks different than the directory structure that's described by the Boost 'getting started' page - notably in that it doesn't contain either the bootstrap.sh script or the b2 binary. This makes me think that brew install boost has taken care of it.
Can someone suggest a next step?
UPDATE 1: Corrected statement about bootstrap.sh and b2.
The solution, provided by someone on the Homebrew mailing list, was to compile my program using the following flags:
c++ -DBOOST_LOG_DYN_LINK -lboost_log-mt trivial_log_test.cpp
Since I got the Boost "bottle", I got prebuilt versions of the binary libraries. No need for bootstrap.sh / b2.
Hi I'm using openGL and doing a nehe tutorial but when I compile in visual studio 2015 I've got this error (sorry for the italian but I think it can be easily understood)
Gravità Codice Descrizione Progetto File Riga
Errore LNK1120 2 esterni non risolti lesson7 C:\Users\Pasto\Desktop\NEHE\Lesson07\Debug\lesson7.exe 1
Errore LNK2019 riferimento al simbolo esterno _sscanf non risolto nella funzione _GetRegistrySysColors#8 lesson7 C:\Users\Pasto\Desktop\NEHE\Lesson07\glaux.lib(tk.obj) 1
Errore LNK2019 riferimento al simbolo esterno _vsprintf non risolto nella funzione _PrintMessage lesson7 C:\Users\Pasto\Desktop\NEHE\Lesson07\glaux.lib(tk.obj) 1
It works on VS2013 but if I run it on VS2015 it doesn't work.
Any idea? Thanks
Go to the properties of your project, Linker and Input, add in the Additional Dependencies this line : legacy_stdio_definitions.lib
#pragma comment(lib, "legacy_stdio_definitions.lib")
Add this line in your hfile like:
#include <XXXX.h>
...
#pragma comment(lib, "legacy_stdio_definitions.lib")
It's work for me
I tried to build my app that uses glib-2.0 with Visual Studio.
The glib-2.0 was installed with pacman from msys2, so I haven't got glib-2.0.lib but I have glib-2.0.a
When I set glib-2.0.a and intl.a in Additional Dependencies from Visual Studio 2013, I got this errors:
Erreur 2 error LNK2001: symbole externe non résolu ___chkstk_ms C:\Users\julien\Documents\Visual Studio 2013\Projects\m\m\libintl.a(loadmsgcat.o) m
Erreur 66 error LNK2001: symbole externe non résolu __imp_getsockopt C:\Users\julien\Documents\Visual Studio 2013\Projects\m\m\libglib-2.0.a(giowin32.o) m
etc etc ...
I have set intl.a too because pkg-config --libs glib-2.0 --msvc-syntax returns:
/libpath:C:/msys64/mingw64/lib.lib glib-2.0.lib intl.lib
What I have to do to build my app?
You need to build GLIB with MSVC.
I tried now almost a week to build a reliable boost + ICU libraries under Windows and VC++ as STATIC libraries under x86 system (so I won't need any runtime dll's when). I mostly need boost regex with Unicode support and boost.locale.icu.
Couldn't find all over the web any reliable solution (not on boost site or ICU) for doing this. Tried building with VC++, Cygwin + VC++ but no success so far. Any help from experience? Or, the worse scenario, any pre-build ICU static + boost static packages?
After I built ICU static, configured under Cygwin:
bash runConfigureICU --enable-debug --disable-release Cygwin/MSVC --prefix=/cygdrive/c/icu/dist --enable-static --disable-shared
got the following static libraries:
02/17/2014 12:57 AM 23,505,784 sicudt.lib
02/17/2014 12:56 AM 7,922,572 sicuin.lib
02/17/2014 12:56 AM 101,218 sicuio.lib
02/17/2014 12:56 AM 1,507,686 sicule.lib
02/17/2014 12:56 AM 157,632 siculx.lib
02/17/2014 12:56 AM 190,472 sicutest.lib
02/17/2014 12:56 AM 1,749,872 sicutu.lib
02/17/2014 12:56 AM 4,584,154 sicuuc.lib
I built boost as static against ICU libraries:
bjam --toolset=msvc-10.0 --build-dir="C:\local\build" address-model=32 threading=multi link=static runtime-link=static -sHAVE_ICU=1 -sICU_PATH="C:\icu" -sICU_LINK="/LIBPATH:C:\icu\lib sicuuc.lib sicuin.lib sicudt.lib"
then, when trying a simple code I get unresolved symbols, so something is wrong with my compiled libs:
cl.exe /MT /EHsc /O2 /I C:\local
\boost_1_55_0 uniregboost.cpp /I C:\icu\include /link /SUBSYSTEM:CONSOLE advapi3
2.lib sicuuc.lib sicuin.lib sicudt.lib /libpath:"C:\local\boost_1_55_0\stage\lib
" /libpath:"C:\icu\lib"
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
uniregboost.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:uniregboost.exe
/SUBSYSTEM:CONSOLE
advapi32.lib
sicuuc.lib
sicuin.lib
sicudt.lib
/libpath:C:\local\boost_1_55_0\stage\lib
/libpath:C:\icu\lib
uniregboost.obj
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in LIBCMT.lib
(memmove.obj)
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(
malloc.obj)
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _realloc already defined in LIBCMT.lib
(realloc.obj)
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _free already defined in LIBCMT.lib(fr
ee.obj)
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _wcslen already defined in LIBCMT.lib(
wcslen.obj)
MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strtoul already defined in LIBCMT.lib
(strtol.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_in
fo(class type_info const &)" (??0type_info##AAE#ABV0##Z) already defined in LIBC
MT.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall
type_info::operator=(class type_info const &)" (??4type_info##AAEAAV0#ABV0##Z) a
lready defined in LIBCMT.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; us
e /NODEFAULTLIB:library
uniregboost.obj : error LNK2019: unresolved external symbol "private: class boos
t::basic_regex<int,class boost::icu_regex_traits> & __thiscall boost::basic_rege
x<int,class boost::icu_regex_traits>::do_assign(int const *,int const *,unsigned
int)" (?do_assign#?$basic_regex#HVicu_regex_traits#boost###boost##AAEAAV12#PBH0
I#Z) referenced in function "public: class boost::basic_regex<int,class boost::i
cu_regex_traits> & __thiscall boost::basic_regex<int,class boost::icu_regex_trai
ts>::assign(int const *,int const *,unsigned int)" (?assign#?$basic_regex#HVicu_
regex_traits#boost###boost##QAEAAV12#PBH0I#Z)
uniregboost.obj : error LNK2019: unresolved external symbol "public: class std::
vector<int,class std::allocator<int> > __thiscall boost::re_detail::icu_regex_tr
aits_implementation::do_transform(int const *,int const *,class icu_52::Collator
const *)const " (?do_transform#icu_regex_traits_implementation#re_detail#boost#
#QBE?AV?$vector#HV?$allocator#H#std###std##PBH0PBVCollator#icu_52###Z) reference
d in function "public: class std::vector<int,class std::allocator<int> > __thisc
all boost::re_detail::icu_regex_traits_implementation::transform(int const *,int
const *)const " (?transform#icu_regex_traits_implementation#re_detail#boost##QB
E?AV?$vector#HV?$allocator#H#std###std##PBH0#Z)
uniregboost.obj : error LNK2019: unresolved external symbol "public: bool __this
call boost::icu_regex_traits::isctype(int,unsigned __int64)const " (?isctype#icu
_regex_traits#boost##QBE_NH_K#Z) referenced in function "private: bool __thiscal
l boost::re_detail::perl_matcher<class boost::u8_to_u32_iterator<class std::_Str
ing_const_iterator<char,struct std::char_traits<char>,class std::allocator<char>
>,int>,class std::allocator<struct boost::sub_match<class boost::u8_to_u32_iter
ator<class std::_String_const_iterator<char,struct std::char_traits<char>,class
std::allocator<char> >,int> > >,class boost::icu_regex_traits>::match_word_bound
ary(void)" (?match_word_boundary#?$perl_matcher#V?$u8_to_u32_iterator#V?$_String
_const_iterator#DU?$char_traits#D#std##V?$allocator#D#2##std##H#boost##V?$alloca
tor#U?$sub_match#V?$u8_to_u32_iterator#V?$_String_const_iterator#DU?$char_traits
#D#std##V?$allocator#D#2##std##H#boost###boost###std##Vicu_regex_traits#2##re_de
tail#boost##AAE_NXZ)
uniregboost.exe : fatal error LNK1120: 3 unresolved externals
I didn't forget to add the static flag for ICU in my code:
#define U_STATIC_IMPLEMENTATION
UPDATE:
rebuilt all ICU and Boost static, now I have only one error linking:
cl.exe /MT /EHsc /O2 /I C:\lib\b
oost-1.55.0-vs2010\include\boost-1_55 uniregboost.cpp /I C:\lib\icu-52.1-vs2010\
include /link /SUBSYSTEM:CONSOLE advapi32.lib sicuuc.lib sicuin.lib sicudt.lib s
icuuc.lib /libpath:"C:\lib\boost-1.55.0-vs2010\lib" /libpath:"C:\lib\icu-52.1-vs
2010\lib"
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
uniregboost.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:uniregboost.exe
/SUBSYSTEM:CONSOLE
advapi32.lib
sicuuc.lib
sicuin.lib
sicudt.lib
sicuuc.lib
/libpath:C:\lib\boost-1.55.0-vs2010\lib
/libpath:C:\lib\icu-52.1-vs2010\lib
uniregboost.obj
Creating library uniregboost.lib and object uniregboost.exp
libboost_regex-vc100-mt-s-1_55.lib(icu.obj) : warning LNK4217: locally defined s
ymbol ??0Locale#icu_52##QAE#ABV01##Z (public: __thiscall icu_52::Locale::Locale(
class icu_52::Locale const &)) imported in function "public: class icu_52::Local
e __thiscall boost::re_detail::icu_regex_traits_implementation::getloc(void)cons
t " (?getloc#icu_regex_traits_implementation#re_detail#boost##QBE?AVLocale#icu_5
2##XZ)
libboost_regex-vc100-mt-s-1_55.lib(icu.obj) : warning LNK4217: locally defined s
ymbol ??0Locale#icu_52##QAE#XZ (public: __thiscall icu_52::Locale::Locale(void))
imported in function "public: class icu_52::Locale __thiscall boost::icu_regex_
traits::getloc(void)const " (?getloc#icu_regex_traits#boost##QBE?AVLocale#icu_52
##XZ)
libboost_regex-vc100-mt-s-1_55.lib(icu.obj) : warning LNK4217: locally defined s
ymbol ??1Locale#icu_52##UAE#XZ (public: virtual __thiscall icu_52::Locale::~Loca
le(void)) imported in function "public: __thiscall boost::re_detail::icu_regex_t
raits_implementation::~icu_regex_traits_implementation(void)" (??1icu_regex_trai
ts_implementation#re_detail#boost##QAE#XZ)
libboost_regex-vc100-mt-s-1_55.lib(icu.obj) : error LNK2019: unresolved external
symbol "__declspec(dllimport) public: static class icu_52::Collator * __cdecl i
cu_52::Collator::createInstance(class icu_52::Locale const &,enum UErrorCode &)"
(__imp_?createInstance#Collator#icu_52##SAPAV12#ABVLocale#2#AAW4UErrorCode###Z)
referenced in function "public: __thiscall boost::re_detail::icu_regex_traits_i
mplementation::icu_regex_traits_implementation(class icu_52::Locale const &)" (?
?0icu_regex_traits_implementation#re_detail#boost##QAE#ABVLocale#icu_52###Z)
uniregboost.exe : fatal error LNK1120: 1 unresolved externals
I'm not allowed to comment yet, so I'm giving my comment as an answer (sorry for the inconvenience), for I'm struggling with exactly the same issue. I detected following test file:
<boost>\libs\locale\build\has_icu_test.cpp
with these lines of code:
#if defined(_MSC_VER) && !defined(_DLL)
#error "Mixing ICU with a static runtime doesn't work"
#endif
Maybe (at least on Windows) a static boost with ICU compilation is not possible?
You are building the right way. The problem is that the Boost.Locale build system does not seem to have any code to detect the static ICU libraries and therefore even if you set all the correct parameters it does not pick up the libraries as expected. If you inspect these files:
libs\locale\build\Jamfile.v2
libs\regex\build\Jamfile.v2
you will notice that there seems to be no code to probe for sicuXX.XXX files. I think this may be the problem.
There is a feature request for this on the boost bug tracker: https://svn.boost.org/trac/boost/ticket/9685
It may help if more people show their interest in this being implemented.
edit M:\work\code\qt\icu4c-68_2\icu4c\source\runConfigureICU
find Cygwin/MSVC
replace -MD -MDt to -MT -MTd