How to add 3rd party library in Unreal Engine 4 - c++

I am new to Unreal Engine. But here is what I planned to do. I want to an experiment project by combining socket.io with Unreal Engine 4. I know somebody may shot at me, for it already had a plugin. But I don't like graph programming at all (I prefer "real" coding)
But as I followed instruction from Installing socket.io C++ and here. It just won't work. The error told me something about File Not Found on multiple headers file from this github repo. So I tried to add a lot of things (Hopefully it won't affect the outcome). And now a tons of errors had popped up. Now they are mostly about Macro errors. And I have absolutely no idea how to fix.
The problem is I don't understand why after I include .lib files to PublicAdditionalLibraries I still needed the original file (Shouldn't it work like any other visual studio projects?)
Also how to tackle loads of errors I am facing
Thanking in advanced

Did you add your include paths with the lib headers to PublicIncludePaths array ( in the StartupModule() method ? it's gonna be needed to use methods from your lib.
Here is an exemple how to use the PublicIncludePaths
string includePath = Path.Combine(ThirdPartyPath, "opencv", "include");
PublicIncludePaths.Add(includePath);
ThirdPartyPath is a member of my module class i retrieve with my getter
Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/"));
I took a look at the github repo of Socket-IO-cpp lib and the only libs compiled for windows are in 32bits, take care you're not tried to compile in 64bits, or every .lib files of your libraries are in 32bits to be linked all together, in case you're using others libs.
If you got some runtime error, take a look at my answer which explain how to indicate .dll when .libs arn't enough.
Hope it helps

Related

Trouble installing C++ libraries from Github

I've used C++ for several courses in university but the libraries we used in these courses were quite simple to install. When we came across libraries which required a bit more complex installation, our teachers always provided detailed instructions.
This time I'm doing a project on my own. I have downloaded libraries for my own projects in the past. Sometimes the install was easier, sometimes I had to search for hours to do things most people here would do in 5 minutes.
I did some studying to remember some stuff about the compiling process, what dynamic and static libraries are, etc. I feel I understand the most part but it didn't really help me with my efforts to install some libraries. Some people in Github provide instructions for newbies like me, but others, understandably, don't.
I'm saying a lot so I'll get to the point. I will provide links for the library I'm trying to install but in case I'm not allowed to, please let me know so I can rewrite this in a way that is allowed.
I'm trying to install libccd so I can then install fcl. In the instructions 3 ways are mentioned:
Using Makefile
Using autotools
Using Cmake
In all 3 methods, I see specific commands like this :
First of all, where am I supposed to write these commands?
I don't even know how to search this. So, I tried installing with methods I've previously used.
Here are the steps I took:
Downloaded the whole repository.
Made a solution for Visual Studio with Cmake-gui (that's all I know how to do with Cmake,unfortunately it usually was enough so I never learnt more)
Compiled the code in Release mode, which should give me a lib file.
Now,in my own project, I added the relevant include directories of the repository I downloaded and the library directory for the lib file which was produced.
I'm not sure about my last step. I'm pretty sure if I did the installation as proposed in the link(and as required by fcl), I would have a new folder for the library including just an include folder and a lib folder. Now I'm just searching for the correct include files and the lib file in subfolders of subfolders hoping I include the right ones. I'm a bit lost.
I'd really like some general steps(if there are) to installing a library. I know each library has its own ways but I assume the general idea with Cmake or Makefile should be the same. I have tried searching online but I didn't come across a good or detailed enough tutorial. I really don't wanna waste any more days trying to install libraries and I don't want to end up asking here again.
UPDATE:
It looks like there is no standard way to install libraries. Since I'm getting 'close votes' I'll include a specific question:
Are the steps I took correct? What should I do next?
I'm trying to install libccd so I can then install fcl. In the instructions 3 ways are mentioned:
Using Makefile
Using autotools
Using Cmake
In all 3 methods, I see specific commands like this :
First of all, where am I supposed to write these commands?
These instructions are for a UNIX-like system. Makefiles, autotools... these are UNIX things. You'd typically write those build commands into a console window on something like Linux or a Mac.
CMake is a bit more cross-platform. You can find out how to invoke CMake on other SO questions.
You can get Makefiles and such to work on Windows, using projects like Cygwin and MSYS. I'd generally recommend you avoid that unless you really need it.
I'm not sure about my last step. I'm pretty sure if I did the installation as proposed in the link(and as required by fcl), I would have a new folder for the library including just an include folder and a lib folder. Now I'm just searching for the correct include files and the lib file in subfolders of subfolders hoping I include the right ones. I'm a bit lost.
This is where no "general" advice exists. Different authors put their output in different places. If their instructions didn't include this information, you're already doing the right thing. If you get really stuck, you can always just ask them.
I'd really like some general steps(if there are) to installing a library.
No such thing exists, but where these industry-standard tools are involved, you can usually go on general documentation for those tools, or from memory.
I also suggest you shop around for a general book on programming, as general principles should be covered in any good one of those.

How should/could/must I handle the dll that my C++ projects depend on?

I'm lost here and I have no clue how to proceed. This is not a question about how to make my program work, this is a question about how to stop wasting my time.
My programming environment is Visual Studio 2013 on windows, in C++.
I use 3 libraries extensively, namely: boost (using dynamic linking), OpenCV, and Qt.
During the development, I have configured VS to look at those 3 libraries by default for include and .lib. I have also added the 3 folders containing all the dlls to my PATH environment variable.
It works, but it is sometime painful, let me explain you when.
First hassle: Anytime I have a LNK error telling me I miss a function, it is usually on OpenCV since it has only one include file referencing all the functions. I have to look at OpenCV's source code to see what module this function belongs to and to know what I must link my program to.
Second Hassle: When comes the time to deploy my application, I have to ship it with all the relevant dlls. To know which one I need, I open dependency walker and try to forget nothing, I have then to test it on a different computer because 102% of the time I have missed a couple, and then I have to configure my Installer generator to include all those one by one.
Third Hassle: To ease a little bit the process of configuring a new development machine, I have recently switched to NuGet. It is great, I add boost with a couple of clicks to any project. But now my boost DLLs are everywhere, I have one folder per boost library, and since there are dozens of those I can't even add them all at once to my PATH now, so I have to move them manually to the appropriate folder, and that is really not what I want to do with my not-so-precious-but-who-are-you-to-judge time
I have looked around and couldn't find any good practice regarding this issue, maybe because they are too obvious, or too specific to a particular setup.
How do you do? How would you do if you were me?
We put all our external dependencies in version control along with the code. This ensures that all code can build "out of the box" on any of our development machines and also ensures that for any given version of the code, we know exactly which dependencies is has.
The best way to check for missing dependencies is how have a good automated test suite, if you've got comprehensive converge then if your tests pass you must have deployed the required libraries.
In terms of linking to the appropriate libraries, unfortunately, that just sounds like an issue with the structure of OpenCV (I'm not familiar with OpenCV). I tend to use dumpbin under Windows and nm under Linux to easily grep for symbols when I get link errors with an unfamiliar library.

Why are there no header files to include when building LuaPlus?

From this question's answer, it seems as though this should be simple: How do you include LuaPlus into your project?
This is absolutely ridiculous though. It is so dumb that you have to build this (along with such an awful website), but there are absolutely no tutorials on this either. Horrible documentation on getting it installed.
I read something about building it using the "jam" stuff, but that is alien lingo to me and sounds asinine. Why not just make this simple? Most libraries just let you download them straight up, extract, link, and wallah! I've built libraries before, and it was extremely simple and easy.
Anyway, I successfully built the library in Code::Blocks, but that isn't the problem. The problem is it only builds the library. Where are the header files to add to the include directory?
I tried messing around, but I had errors just dumping what I thought the header files were into a directory and including it.
I read online, people who use Visual Studio to build don't have a problem, and it creates all the header files. The only thing that results from my Code::Blocks build is the library file.
This is a PITA just to get to use, and I've already been at it 2 hours and the only way I can work with it is if I include the entire source in my project (which is just ridiculous).
edit2: Ergh! LuaPlus edits Lua itself, so you have to remove your link to Lua. LuaPlus has Lua in it. So F***ing ridiculous. Just let people download the library and just link simply for god's sake. A huge middle finger to needlessly complicated crap.
edit: Nevermind, this isn't the correct answer. Now I'm getting all kinds of stupid errors.
I guess the first time I copied over all the header files, I did something wrong because now it works just as it should.
For anyone interested, you just copy/paste all of the header files (shown here
Minus LuaPlusAll.cpp, src/lua.c, and src/luac.c
Then paste them in your search directory
lib/libLuaPlus.a
include/[paste here]
Link the library & include directory, tell Code::Blocks to use "libLuaPlus" and wallah!
No idea why I had problems with this. Must have been following someone's bad directions (causing me to mess up somewhere).

How to convert a cmake project into a Visual Studio equivalent?

The situation is the following: I have the source code of one programm (lets call it programA) (written in C and C++), as well as the CMakeLists.txt and CTestConfig.cmake files. I already installed programA using CMake's graphical user interface and, as it is obvious, it worked. It created the .exe file (I'm working on Windows 7 OS).
The problem is that, right now, I've been asked to edit the program (and so, I must be able to edit the code and degugging it as changes are made). I also need to compile it but not in .exe anymore but in .dll so I can add it to a website we have.
I've read in forums that CMake can compile programA into a .dll if I need to, but as I would need to make some changes I consider that CMake debugging is not as useful and easy as using entirely VS. From the little I know from CMake language, the CMakeLists.txt is mainly used to check the OS of the user as well as adding some libraries in case they are not found.
I have to admit I have no idea in programming CMake directives, as I have been working with ASP.NET, C, C++ and C# mostly. Then, my idea is to try to work only in visual studio 2010 instead of using cmake as well, so once I have the program 'adapted' to VS and can be compiled just using VS, I'm ready to start my job. So the question I have is how can I perform the same task CMake did just using Visual Studio (Is there any way of implementing CMake directives in VS?), can VS compile by receiving as an argument something similar to that CMake.txt file (though it needs to be translated into another language)?
To skip the use of CMake I tried to copy the source code into a new project in VS. However as it does not use the CMake directives when compiling, it gives several errors, most of them related to the fact that some headers.h can't be found (cause they might be in a subfolder). And there are so many subfolders to add the paths to the predefined directories of search that it would take ages.
I'm sorry I can't be more precise in my explanation. I'm good at programming little projects on my own, but it's the first time I have to work on other's programm. Please don't hesitate to ask if anything was not properly understood
I would appreciate a lot any suggestion / advice /guidance you can give.
To make a dll, use add_library command and the SHARED keyword
add_library(mylib SHARED ${files})
this is easy with CMake, don't go back in visual that will be harder at the end
The Good News
Fortunately, cmake can generate VS Projects automaticaly for you (this tutorial s specific for OpenTissue, but Steps 1 to 3 should be the same for you).
The [not so] Bad News
Depending on the complexity of the project, VS Projects automaticaly generated by cmake can get pretty nasty, to the point of illegibility. It will, for example, hard link any library dependencies using the specific paths of your machine, so the project will most certainly not be portable across setups. In any case, that's the intended bahavior, because the primary idea of supporting this generator is simply making it work, thus allowing users to easily compile projects using MSVC, so there's not much you can do here. Nonetheless, it should work in your machine and will certainly be a great starting point for you, just create a project yourself from scratch copying the relevant parts out of the automatic generated version.

SuperLU library XCode issues

I'm a newbie when compiling and adding 3rd party C++ libraries into XCode... So here's the problem. I have .cpp files wich depend on 3 libraries. OpenCV-Eigen-SuperLU. So far think that I managed to add correctly OpenCV-Eigen, but I got trouble adding SuperLU.
I'm really confused on where should I include source files paths??. Some tutorials say that I need to create a static lib... other that I need a framework... on the other hand there are XCode project template which just include src files into a folder inside XCode project's and then reference them from build setting properties. Anyway I really need some guidance here.
So here's my setup for most of the libs. I have a folder within the XCode project with all dependencies.
Then... on project build settings I setup header search paths-- and library search paths. To point that folder
Headers for SuperLU are found correctly... but I get Linker errors.
So as you can see, I have no idea what to do... I'm Sorry but as I told on beginning I'm a newbie adding libs into XCode... plus documentation of procedures it's not good at all. So if anybody could help me with some guidance or links where I can start understanding how the linking process works would be great.
I'm a little desperate at this point, os any kind of help would be really really great.
Thanks a lot.
The problem is that both SuperLU and Objective-C define YES and NO. So you get a conflict.
In the end I was advised to create a different target to compile all SuperLU as a pure c++ project with gcc compiler. That made it possible for iOS app to use the lib as a dependency.