Building MuPdf and registering document handlers - c++

Here we have a question, an answer and some happy people.
But I've got a different situation,
I'm coding in C++ and I'm going to build MuPdf myself.
So, when i add fz_register_document_handlers function before fz_open_document_with_stream I'll get 5 unresolved external symbols for these
_opj_image_destroy (2 times)
_opj_copy_image_header
_opj_image_comp_header
_opj_image_create
I can get rid of 3 of them by linking openjpeg\libopenjpeg\image.c but _opj_image_destroy is stock on my compiling error list!
[UPDATE]
Mupdf version: 1.6
I don't know that it's a right way or not but I created a visual studio project, named Native and put Mupdf source in it and try to compile.
Then i'm using it's header in other c++ project (and using declare "C" in it) and linked Native to it.
It works fine until i trying to open a file as a stream and not file address.
So, my project failed with this error: "No document handlers registered".This error is caused by document.c file.
I searched and find the page which was linked above and I changed the source.
The compile errors appeared after that change!
Thanks for your help and sorry for my English...

Firstly, you haven't said what version of MuPDF you are using. I'm going to assume you're using the latest version from git (currently 1.6 as of 1 Feb 2015).
Secondly, you've not told us anything of use about how you're building MuPDF. Without knowing exactly what you've changed, it's hard to speculate what you're doing wrong.
If you're compiling vanilla .c files with a c++ compiler then you probably need to do some wrapping of files with extern "C" declarations.
Feel free to get in touch on the #ghostscript irc channel and tell us more.
[Update]
It sounds to me like you are missing the openjpeg decoder. You can't just add a single file from the openjpeg source and expect it to magically work.
Why are you creating your own Visual Studio project when we provide one for you already? platform/win32/mupdf.sln

Related

How to get wxWidgets working in Visual Studio 2012

I've got a problem for which I would very much like a solution please:
All I'm trying to do is use wxWidgets in Visual Studio 2012 (in C++), and make it accessible to my code project. That shouldn't be so hard, should it? But as usual, even though there are programming tutorials for it, wxWidgets is evidently one of those things that has no proper documentation just to simply get it running, or if it does then I sure can't find it.
I downloaded the installer for Windows and installed it. When it finished, it gave me a message that said:
wxWidgets was installed successfully!
Please note: before using wxWidgets in your application,
you must build the library using the same compiler you
use for building your program.
Please see docs/msw/install.md file in the installation
directory for the detailed instructions about how to build
wxWidgets and use it from your application.
It should be noted that I think I remember something on the website or somewhere saying that I can just include a header file into my project and forego the DLL altogether (which is what I'd prefer to do, if possible), though I may possibly be misremembering that or confusing it with something else.
Anyway, when I opened the docs/msw/install.md file, I found (amongst other things) these instructions:
--- From the IDE
Ready to use project files are provided for VC++ versions 8, 9,
10, 11, 12, 14, 15, 16 and 17 (also known as MSVS 2005, 2008, 2010, 2012,
2013, 2015, 2017, 2019 and 2022 respectively).
Simply open wx_vcN.sln (for N=8, 9, 10, 11, 12, 14, 15, 16 or 17) file,
select the appropriate configuration (Debug or Release, static or DLL)
and build the solution. Notice that when building a DLL configuration,
you may need to perform the build several times because the projects
are not always built in the correct order, and this may result in link
errors. Simply do the build again, up to 3 times, to fix this.
Of course, it doesn't even say WHERE the "wx_vcN.sln" files are, but I ran a file search and found them in C:\wxWidgets-3.1.6\build\msw and I opened the one called wx_vc11.sln, because that seems to be the one that corresponds to VS2012, right?
Anyway, it took a LONG time to load, because it had to keep scanning through thousands of files and so forth, but when it was finally finished, I did the "Rebuild All" command thrice in a row, like it says to do (which also took a while).
But I'm not sure where it even put the actual DLL file. It says that it's in C:\wxWidgets-3.1.6\build\msw....\lib\vc_lib\wxmsw31ud_xrc.lib, but where the hell is "...."? It doesn't even bother to specify the entire path! What kind of nonsense is that?! I just want the file so that I can put it into my project! Or better yet, just a .h file that takes care of everything would be great. Supposedly there's one to include called "wx/wx.h", which then includes everything else, I think, but I don't know if that one indirectly also requires a DLL.
I always have problems with DLLs, anyway, though I'll use one if I absolutely have to. You'd think it would be the easiest thing to import a DLL into a project, but for some reason, I've never been able to find any sort of tutorial that explains a specific, step-by-step way to do it which is guaranteed to work, so on the rare occasion that I actually need to use a DLL (99% of the time I can just rely on my own code and the .h files included with Visual Studio), I always end up muddling through it until it FINALLY works by sheer accident (if I'm lucky). Mostly, it just reports errors for one reason or another, that it's not properly included or compatible, or that the header files that I'm using which reference it keep showing the same errors, as though I hadn't even imported the DLL file at all! I've been programming for about 30 years, and I work on things like AI and compression and cryptographic algorithms. I don't say this to brag, but to point out that if someone as experienced as me has trouble getting a DLL to attach properly to a roject, then there's something severely wrong with the whole process, or the documentation for it! I HATE using DLLS, because it's always a HUGE chore, but I'll do it if there's absolutely no other way (though I'd appreciate step-by-step instructions, if you don't mind).
But enough about that. In any case, I have an example project in which wxWidgets is being used in conjunction with Vulkan, and though it has compilation errors (because Vulkan didn't properly install on my machine (when I try to run the sample programs it says they're missing DLLs - big surprise) and as it turns out, I don't think it's compatible with my video card, anyway (which might possibly be why it didn't install properly), so I think I'll have to resort to OpenGL instead - PLEASE tell me that's compatible with wxWidgets!), but even in that example project, it has errors where it's trying to include and use wxWidgets stuff (like "wx/wx.h"), even though that's supposed to be a complete and already working project! I can't find any DLL files or the header files in question anywhere in the project directories!
So anyway, there's got to be an easier way to get this all set up, just to the point that I can make a simple test program using wxWidgets, and compile it. I'd REALLY like to be able to get at least that much working sometime tomorrow morning, so I'd greatly appreciate any help you can give me! Thank you.
#ThisIsMe,
First of all you need to educate yourself on properly using C++.
When you acquire the C++ code it contains of 2 portion - header file and source code.
Header file is what you call a declaration you declare you classes there - class name, member variable and method.
In the source files You define what you declared and you put an actual code there.
Now with that in mind:
wxWidgets contains both header and source files. When you downloaded the installer and did the installation it just copied the "text file" (headers and sources) into the folder of you choice.
Now as you can imagine text files are not executable - you need to compile them into the binary files And that is exactly what you did. (I don't know why you did it 3 times though - I guess you got an errors after building 1st and 2nd time).
Now, you said you have a project that (either uses wxWidgets or you want to incorporate wxWidgets into - which one is it, BTW?). The answer to this question will help direct you to a proper solution.
Now, you said that you tried the Vulkan and it fails to run the demo. How did it fails? Did it produce an error? What was it? Did it even run?
Now wxWidgets does support OpenGL as can be seen by looking at the documentation and checking the different samples that comes with the library, but I'm just curious if what you are seeing from Vulkan is really an incompatibility with the Video Card.
So, we need you to answer the questions I put and so we can help you further. Just keep in mind - C++ is not for the beginner programmers and if you are struggling with understanding the difference between compilation, installation , headers and sources - it will be very hard for you.
Maybe you should start with something simpler - like wxPython and forget about C++ for now.

Where can I find d3dcompiler_43.dll and corresponding lib files?

I am trying to make a "hack" for a really old game. My dll injector does not resolve dll import and everything work just fine except D3DCompile function that is causing access violation. After long debugging session I figured out that it is causing this error because my code is referencing to d3dcompiler_47.dll but game has only d3dcompiler_43.dll in it. My question is where can I get corresponding libraries that will (after including to project) use d3dcompiler_43.dll?
Only thing that I have found was a dll D3DCompiler_43.dll which was inside Jun2010_D3DCompiler_43_x64.cab.
Where can I find the header files and lib files for this d3d compiler version?
EDIT: Found all files in Unreal Engine source code.
D3DCompiler is normally part of the windows SDK, which can be found at here. Note that if your game is old enough you may need to download an older version of the SDK (if it uses Direct3D 9 or earlier for example) but I can't tell you exactly how far back you would need to go.

Including C++ sources in a Haskell project

I'm trying to make a data structure that will be exposed in Haskell, but implemented in C++. So far I've implemented it in a .cpp file, declared all the functions I need as extern "C" and added the source file to the c-sources field in the .cabal file. When I build the project (in this case with stack build) it seems to build fine.
I know it's doing something to the C++ file because it doesn't compile if there are errors.
I've yet to try running the project because it's a library and so far it doesn't have anything "runnable" written, but the repl doesn't seem to work.
When I try running it (stack repl in this case) I get a missing symbol error with some mangled name that may or may not be refer to a name in my file.
unknown symbol `_ZdlPv'
linking extra libraries/objects failed
How can I fix this issue? I've had a similar problem before that I fixed by manually compiling the source into a dynamic library and then use that library in my project. I don't want to do that since it ties me to a platform and since it makes no sense that a simple C++ couldn't be compiled with the project using the tools that GHC already has. I want to be able to put this on hackage.
Is there something I'm missing? If not, is it a bug and are there plans on fixing it?
Ok, I've managed to "fix" this for now.
I added a extra-libraries: stdc++-6, gcc_s_seh-1 to my cabal file and now it works. No idea if this is platform independant but those libraries do get shipped with GHC when I install it through stack.

Google gRPC (C++) building under VisualStudio 2013. Link errors

I'm trying to setup gRPC for my project in Visual Studio. Did everything as described here: http://www.infopulse.com/blog/grpc-framework-by-google-tutorial/. (Trying to compile helloworld example -> Git grpc/examples/cpp/helloworld)
The main problem I'm getting, while compiling:
unresolved external symbol "void _cdecl grcp::FillMetadata
... and so on.
Nothing wrong with protobuf (Everything working)
OpenSSL, zlib - OK.
My Includes:
$(SolutionDir)..
$(SolutionDir)..\include
$(SolutionDir)..\third_party\protobuf\src
$(SolutionDir)\packages\grpc.dependencies.zlib.1.2.8.10\build\native\include
$(SolutionDir)\packages\grpc.dependencies.openssl.1.0.204.1\build\native\include
$(SolutionDir)\packages\gflags.2.1.2.1\build\native\include
$(SolutionDir)\packages\gtest.1.7.0.1\build\native\include
Additional dependencies:
libprotobuf.lib
grpc.lib
gpr.lib
libeay32MDd.lib
ssleay32MDd.lib
Everything in correct folders.
What am I missing here? Maybe some of you have an already working .sln project with all dependencies list? I know that the problem must be connected to some .lib that I'm missing here.
It looks like you're not linking in the grpc++ code. It's unfortunately not a supported target right now, but we're looking to remedy that very soon. I'd really like to be offering a nuget package for C++ users.
If you want to try for now though, make sure you're compiling the vsprojects/vcxproj/grpc++/grpc++.vcxproj project alongside the rest of your code. Let us know how you go (and please file bugs at github.com/grpc/grpc/issues to help us prioritize things).

Using SDL to make a simple game, struggling with linking everything together [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 7 years ago.
I would like to attempt to make a simple game in c++.
So I found really cool series about how to make a game but the creator didn't include how to install different libraries etc.
So, in the tutorials, he gives us this code:
http://gynvael.vexillium.org/ext/vc/game.cpp
As a basic framework to make the game.
From now on I will list for you what I found out and what I think is the problem:
The problem is that when you just try to compile and run it, it will throw tons of errors at you etc.
I needed to link my project to SDL first, which I did and I think it works because there is no major errors or underlined code.
But then, there was a problem with the gl.h file.
So I have figured out that I need to install OpenGL libraries and link them to my visual studio project. I found out that I need FreeGlut and GLEW to run the piece of code from the link above.
So I have linked GLEW fairly easily with my project but there is a problem with GLUT.
Apparently, for unknown for me reason you have to compile the .lib file yourself. And that brought me to a whole new level of problems. So the newest version of GLUT (3.0) doesn't have the visual studio folder in it (In the tar file) so I cannot compile the newest version.
On the other hand, all the older versions have that visual studio folder which allows me to compile the freeglut.lib file and add it to my program's dependencies.
But when I do that, it comes up with an error: LNK1104: cannot open file 'freeglut.lib'
I have no idea why's that because I did everything exactly like in tutorials, multiple times.
I think that it could be because I got the newest version of GLEW, but old (from 2013 I think) version of GLUT, because the newest one doesn't have a folder with visual studio project to compile.
All I need is to make the code (from the link) work.
#EDIT~~~~~~~~~~~~~~~~~~~~~~~~
I have found out that my dependencies folder was in the wrong place and I moved it, instead of the problem with the freeglut.lib file, which seems like has been sorted out (I think I fixed it :D) I get like 5 new errors:
Screenshoot of the error log: http://puu.sh/hD6x5/d5fc1e1be6.png
but none of this rings the bell. Nothing happens either if I doubleclick it.
That error means that you need to link with these three additional libraries:
Glu32.lib
SDLmain.lib
SDL_Image library
You may need to download and build SDL_Image, but the other two should already be part of Windows SDK and SDL respectively.
Oh, and you need to not define a main() function in your own code. It's either the framework code you are using, or even SDL (IIRC) that is doing that for you.