x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Embedding a C++ program in a game project

Hello everyone, I'm trying to embed chatscript in a project I'm working on. Chatscritpt is an open source chatbot C++ program, but it's meant also to be embedded in bigger applications.

First of all I assured myself that it was compilable with vs2015 (Chatbot is shipped with a vs2010 project) and it is. Then I just added the source code (actually the whole folder of chatcript) in the game directory inside the source folder of my unreal project, and that's here were my problems started.

Thanks to the complaints of the compiler and google I discovered that I had to wrap all the windows related include with:

 #include "AllowWindowsPlatformTypes.h" 
 #include "HideWindowsPlatformTypes.h"

And I had to include the chatcript common.h also in the unreal files I have (for now just an Actor class, and the main class of the project). Now though I'm stuck with these errors:

 1>  Compiling game modules for hot reload
 1>  Performing 41 actions (4 in parallel)
 1>  PCH.common.h.cpp
 1>C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h(156): error C2039: 'DWORD': is not a member of '`global namespace''
 1>C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h(160): error C2039: 'FLOAT': is not a member of '`global namespace''
 1>C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h(176): error C2039: 'INT': is not a member of '`global namespace''
 1>C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h(177): error C2039: 'UINT': is not a member of '`global namespace''
 1>C:\Program Files (x86)\Windows Kits\8.1\include\um\winnt.h(147): fatal error C1189: #error:  "No Target Architecture"
 1>  -------- End Detailed Actions Stats -----------------------------------------------------------
 1>ERROR : UBT error : Failed to produce item: [project path]
 

I'm new to C++ (but not new to programming, I know Java and C#), I think there is still some problem with some windows include but this time google didn't help me, and I have no clue. Some of you have some suggestions?

Product Version: UE 4.10
Tags:
more ▼

asked Feb 26 '16 at 11:11 PM in C++ Programming

avatar image

Maggese
55 4 6 9

avatar image Shadowriver Feb 26 '16 at 11:35 PM

maybe try include windows.h before common

avatar image Maggese Feb 27 '16 at 12:18 AM

Unfortunatly I cannot do that the compiler says I need common.h as first include:

 EXEC : error : All source files in module "unreal_dontmakelove" must include the same precompiled header first.  Currently "[...]\Source\unreal_dontmakelove\ChatScript-6.2.b\SRC\common.h" is included by most of the source files.  The following source files are not including "[...]\Source\unreal_dontmakelove\ChatScript-6.2.b\SRC\common.h" as their first include:
     1>
     1>  [...]\Source\unreal_dontmakelove\ChatbotEngineCore.cpp (including C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\Core\Public\Windows\AllowWindowsPlatformTypes.h)
     1>  [...]\Source\unreal_dontmakelove\unreal_dontmakelove.cpp (including C:\Program Files (x86)\Epic Games\4.10\Engine\Source\Runtime\Core\Public\Windows\AllowWindowsPlatformTypes.h)

By the way windows.h is included inside common.h I tried nonetheless to include it again as second in the unreal files, but the compiler still gives the same errors.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I solved the problem, here are the steps:

  1. Include the source files of the program you want to embed in the source folder of your Unreal project

  2. After you're sure that the files you added appear in the solution explorer of Visual Studio (refreshing the VS project should be enough) you have to include the header file of your project in each of them (at the beginning).

  3. Compile :-)

In my case I had also to modify the source code to compile without errors. I hope this could help!

more ▼

answered Apr 05 '16 at 06:28 PM

avatar image

Maggese
55 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Could you compile this chatbot as a static library and then bring it in?

https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System

more ▼

answered Feb 27 '16 at 12:14 AM

avatar image

Bino
269 9 5 13

avatar image Maggese Feb 27 '16 at 09:10 PM

Thank you, I followed your suggestion, and now I can compile the project, though I'm unable to use ChatScript. According to the documentation:

To embed CS within a client, you need to perform two calls. To call these routines, your code will need a predeclaration of these routines. The first is

InitSystem(int argc, char * argv[],char* unchangedPath, char* readablePath, char* writeablePath, USERFILESYSTEM* userfiles)

where you pass in various command line parameters to control things like logging or memory usage. Only the first two parameters are required, the remainder being optional and defaulted to NULL.

I predeclared the methods, but I cannot use them. USERFILESYSTEM is not recognized and if I include the common.h (wrapped with the windows includes) to be able to use it than I got an internal error of the compiler:

 [...]\Source\unreal_dontmakelove\ChatbotEngineCore.cpp(9): fatal error C1001: An internal error has occurred in the compiler.
 1>  (compiler file 'msc1.cpp', line 1393)
 1>   To work around this problem, try simplifying or changing the program near the locations listed above.
 1>  Please choose the Technical Support command on the Visual C++
 1>   Help menu, or open the Technical Support help file for more information
 1>  INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe'
 1>      Please choose the Technical Support command on the Visual C++
 1>      Help menu, or open the Technical Support help file for more information

I didn't imagine that could have been so complicated embedding external C++ code in Unreal...

avatar image Maggese Feb 27 '16 at 09:40 PM

I did some other try. I included directly the common.h and wrapped the windows includes that were inside the common.h and now I have again the original problem (the global namespace one).

So basically I cannot include the common.h, but without it I don't know how to call the routines I need.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question