Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Qt / SFML interface  (Read 7935 times)

0 Members and 3 Guests are viewing this topic.

wasabi

  • Newbie
  • *
  • Posts: 23
    • View Profile
Qt / SFML interface
« on: August 09, 2010, 03:08:34 pm »
This sounds like a really, really stupid issue (probably because it is), but I for some reason can't include SFML files into my Qt program (I'm having to bind the SFML program I've built with Qt for its added modular windows [open file, etc] functionality).

For instance, if I write
Code: [Select]
#include <SFML/Graphics.hpp>
I get the build error "Cannot open include file: 'SFML/Graphics.hpp': No such file or directory"

I'm using VC++ 2008 Express and making everything as a makefile, since Qt misbehaves if you do it any other way. However, in the solution properties window, I have "Include search path: [my SFML file path]", just as I have my Qt file path. As well, I find this particularly annoying since it clearly can open the .hpp since VC's Intellisense is working just fine. I type sf:: and it shows me all the possible choices I have. But then I try to build and it goes "wait, what? what file is that?!"

I feel like a shmuck, but why doesn't this work?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt / SFML interface
« Reply #1 on: August 09, 2010, 03:22:42 pm »
Quote
I'm using VC++ 2008 Express and making everything as a makefile

What does this mean? Do you have a .vcproj file, or a .pro? Do you compile with the IDE, or with qmake & nmake?
Laurent Gomila - SFML developer

wasabi

  • Newbie
  • *
  • Posts: 23
    • View Profile
Qt / SFML interface
« Reply #2 on: August 09, 2010, 03:29:26 pm »
I have... both, actually. Which makes the question of which one am I using a tricky one.

I compile through the IDE, but using qmake and nmake.

In the properties window, I've set it up so that the build protocol calls the following code
Code: [Select]
qmake -project && qmake && nmake debug-all

But that's not the problem, I don't think. Qt is working just fine. The problem is only that SFML isn't being included.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt / SFML interface
« Reply #3 on: August 09, 2010, 03:37:44 pm »
You're compiling from the IDE but using an external command; therefore, your global compiler settings are actually ignored.

You should add this to your .pro:
Code: [Select]
INCLUDEPATH += your/path/to/sfml/include
Laurent Gomila - SFML developer

wasabi

  • Newbie
  • *
  • Posts: 23
    • View Profile
Qt / SFML interface
« Reply #4 on: August 09, 2010, 03:51:40 pm »
Thanks, but... VC doesn't let me. Or, well, it does, but then it just erases my work.

If I open and edit the .pro to
Code: [Select]
######################################################################
# Automatically generated by qmake (2.01a) seg 9. ago 10:49:04 2010
######################################################################

TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += "C:\Documents and Settings\pnacht\My Documents\My Dropbox\Libraries\SFML-1.6\include".

# Input
HEADERS += QT.h
SOURCES += QT.cpp


and try to build (be it by Build or Rebuild), it edits the .pro and changes it to
Code: [Select]
INCLUDEPATH += .

EDIT: Indeed, VC actually rebuilds the .pro every time I rebuild the project, as indicated by changes on the time stamp.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt / SFML interface
« Reply #5 on: August 09, 2010, 04:00:54 pm »
You're not supposed to call "qmake -project" every time, as it completely overwrites any change you made.
"qmake -project" is provided for convenience so that you don't have to type the (potentially long) list of source and header files, but after that you must maintain the .pro yourself to add your custom settings.
Laurent Gomila - SFML developer

wasabi

  • Newbie
  • *
  • Posts: 23
    • View Profile
Qt / SFML interface
« Reply #6 on: August 09, 2010, 04:09:03 pm »
Thanks, that works. Now it accepts SFML. I had "qmake -project" for both Build and Rebuild routines.

Twice, it would seem. :p

Code: [Select]
1>c:\Documents and Settings\pnacht\My Documents\My Dropbox\Libraries\SFML-1.6\include\SFML/System/Unicode.hpp(82) : error C2535: 'sf::Unicode::Text::Text(const wchar_t *)' : member function already defined or declared
1>        c:\Documents and Settings\pnacht\My Documents\My Dropbox\Libraries\SFML-1.6\include\SFML/System/Unicode.hpp(80) : see declaration of 'sf::Unicode::Text::Text'


I get that for ::Text(const wchar_t), ::Text(const std::wstring &) and ::Text::operator std::wstring

and the only SFML #include I have is SFML/Graphics.hpp

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt / SFML interface
« Reply #7 on: August 09, 2010, 04:18:45 pm »
QMake sets the compiler option "treat wchar_t as a built-in type" to false, making wchar_t a typedef to unsigned short, which makes functions overloaded for both unsigned short and wchar_t (like the sf::Unicode::Text constructor) fail...

I think the only solution, other than modifying SFML sources, is to change the option "Zc:wchar_t" to "-Zc:wchar_t" in your <qt-root>\mkspecs\win32-msvc2008\qmake.conf file. And then probably recompile Qt.
Laurent Gomila - SFML developer

wasabi

  • Newbie
  • *
  • Posts: 23
    • View Profile
Qt / SFML interface
« Reply #8 on: August 09, 2010, 04:20:23 pm »
......................................

What's the intended means of integrating SFML and Qt, then? Because I'm quite clearly doing something wrong here.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt / SFML interface
« Reply #9 on: August 09, 2010, 06:01:58 pm »
I don't know why QMake sets this option, as far as I remember, Qt still compiles fine if it is disabled. And I don't even know if the C++ standard allows wchar_t to be a non-native type.

The Visual C++ projects/makefiles generated by QMake are generally not that good. Maybe you should install the Qt Visual Studio integration, and work with true VC++ projects rather than QMake.
Laurent Gomila - SFML developer

wasabi

  • Newbie
  • *
  • Posts: 23
    • View Profile
Qt / SFML interface
« Reply #10 on: August 10, 2010, 01:23:36 am »
The integration (add-in) isn't Express-compatible, unfortunately.

And I've had a whole bunch of problems with re-compiling Qt... though I just realized I might have solved those problems when I solved another problem I had with Qt a few days ago, since the error given was the same...

I'll try the recompile, then, and give my feedback here.

wasabi

  • Newbie
  • *
  • Posts: 23
    • View Profile
Qt / SFML interface
« Reply #11 on: August 10, 2010, 05:09:27 pm »
Okay, I was going to change the .conf file, but for me, it's
Code: [Select]
QMAKE_CFLAGS            = -nologo -Zm200 -Zc:wchar_t-

Should I make that Zc:wchar_t- or Zc:whar_t ?

As well, should I alter the .conf file manually (notepad, basically) or is there an advantage to using
Code: [Select]
qmake -set
Because I used
Code: [Select]
qmake -query -Zc:wchar_t and it went sorta-kinda crazy.

Code: [Select]
C:\Qt\4.6.3\qmake>qmake -query Zc:wchar_t
**Unknown**

C:\Qt\4.6.3\qmake>qmake -query -Zc:wchar_t
QT_INSTALL_PREFIX:C:\iwmake\build_vs2008_opensource_________________PADDING_____
____________
QT_INSTALL_DATA:C:\iwmake\build_vs2008_opensource_________________PADDING_______
__________
QT_INSTALL_DOCS:C:\iwmake\build_vs2008_opensource_________________PADDING_______
__________\doc
QT_INSTALL_HEADERS:C:\iwmake\build_vs2008_opensource_________________PADDING____
_____________\include
QT_INSTALL_LIBS:C:\iwmake\build_vs2008_opensource_________________PADDING_______
__________\lib
QT_INSTALL_BINS:C:\iwmake\build_vs2008_opensource_________________PADDING_______
__________\bin
QT_INSTALL_PLUGINS:C:\iwmake\build_vs2008_opensource_________________PADDING____
_____________\plugins
QT_INSTALL_TRANSLATIONS:C:\iwmake\build_vs2008_opensource_________________PADDIN
G_________________\translations
QT_INSTALL_CONFIGURATION:C:/iwmake/build_vs2008_opensource_________________PADDI
NG_________________
QT_INSTALL_EXAMPLES:C:\iwmake\build_vs2008_opensource_________________PADDING___
______________\examples
QT_INSTALL_DEMOS:C:\iwmake\build_vs2008_opensource_________________PADDING______
___________\demos
QMAKE_MKSPECS:C:\iwmake\build_vs2008_opensource_________________PADDING_________
________\mkspecs
QMAKE_VERSION:2.01a
QT_VERSION:4.6.3


It goes without saying that I'm not very good at command prompts. They scare me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Qt / SFML interface
« Reply #12 on: August 10, 2010, 06:30:06 pm »
Quote
Should I make that Zc:wchar_t- or Zc:whar_t ?

In fact you can simply remove it, what you want is the default behaviour ;)

Quote
qmake -set

I don't know this option, I've never used it. Editing the configuration file directly works fine.
Laurent Gomila - SFML developer

wasabi

  • Newbie
  • *
  • Posts: 23
    • View Profile
Qt / SFML interface
« Reply #13 on: December 22, 2010, 05:11:28 pm »
Aaaaaand I'm back with the same problem.

I haven't had to deal with this potential issue for a long time because I realized I didn't need to display the information I wanted on the Canvas itself. However, now I do.

And so I simply added a sf::String to the class
Code: [Select]
struct Fault
{
float maxPPI;
FProperty prop;
std::vector<Segment> segments;
sf::String name;
Fault();
void DefaultColor();
void ViewRatio(float min,float mid,float max);
};


However, if I try to compile the files now, it gives the same error as before:
Code: [Select]
Fault.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Unicode::Text::Text(char const *)" (??0Text@Unicode@sf@@QAE@PBD@Z) referenced in function "public: __thiscall Fault::Fault(void)" (??0Fault@@QAE@XZ)

Thinking that perhaps I've been using the wrong .conf file all along, I checked, but nope, that QMAKE_CFLAGS line is correct:
Code: [Select]
QMAKE_CFLAGS            = -nologo -Zm200

Any other possible reason for this?

EDIT: Well, actually, it's not the same error, but...