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"

How to #include vector <>? or other members of the standard library?

Is it possible to #include within the UE4? I know that UE4 have built there own container types for cross platform compatibility but in my scenario my "game" will always be run on windows (and possibly only on one computer).

Ideally I would like to be able to somehow link to the standard library. Is this possible? For example, somehow link to a .lib containing the standard library? Is this even possible? I am fairly new to c++ so forgive me if it sounds like a silly question!

Thanks

Product Version: UE 4.16
Tags:
more ▼

asked Sep 07 '17 at 02:14 PM in C++ Programming

avatar image

raza91
6 2 5 8

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

2 answers: sort voted first

Hi, yes thats the nature, and its is easy, to integrate a .lib in windows for example or another library for another platform, you have to use the Unreal build system, basically you can define your compiles rules, for instance you can use this inside your Build.cs file:

 PublicLibraryPaths.Add("C:/WhateverLinkToYourLibs");
 PublicIncludePaths.Add("C:/WhateverLinkToYourIncludes");
 PublicAdditionalLibraries.Add("C:/WhateverLinkToYourLibs/YourLib.Lib");

I would like recommend you this wiki: https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System

Also if you began with ue, take a look to every wiki in the page. Cheers

more ▼

answered Sep 07 '17 at 02:37 PM

avatar image

ZkarmaKun
381 9 12 18

avatar image raza91 Sep 07 '17 at 03:06 PM

I've actually had a look at that tutorial and managed to link a static library of my own. However I keep getting errors when I try to use functions which involve vector. I was hoping to find a way of just using the standard library within UE4. That is have parts of my code which entirely use the standard library.

If I wanted to use the standard library do I need to somehow download the standard library in .lib format and then use the mentioned tutorial to link it to my project?

avatar image ZkarmaKun Sep 07 '17 at 03:13 PM

no, that is not about use libraries, by default unreal hates c++ stl really hard , I afraid you will not able to use vector inside UE, port everything to TArray or you can port everything inside a dll, and then call it from UE, without let unreal touch those vectors, otherwise you will be in big trouble

avatar image raza91 Sep 07 '17 at 03:23 PM

Hey, thanks for the response. By port everything inside a dll do you mean turn my exisiting c++ code (which uses STL) into a dynamic library and call that from UE?

For example lets say I build a library which has simple and useless function which takes in three doubles, turns them into a vector and then sums the vector:

     double MyMathFuncs::vectorsum(double a, double b, double c)
     {
         std::vector<double> myVec;
         myVec.push_back(a);
         myVec.push_back(b);
         myVec.push_back(c);
     
         double sum = 0.0;
         for (unsigned i = 0; i < myVec.size(); i++) {
             sum += myVec[i];
         }
 
         return sum;
     }

Can I call this function from within UE by turning the above into a library and linking the library?

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

I was able to resolve my problem by creating a static library that uses the standard library. You must ensure that you are using Visual Studio 2015 update 3 and the static library is built using release 64x. From there you can follow the Unreal tutorial of linking static libraries to UE4 and it should work fine. Although, it does increase build times considerably.

more ▼

answered Sep 08 '17 at 05:17 PM

avatar image

raza91
6 2 5 8

(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