Inclusion of certain libraries causes service not to start C++ (fastcgi) - c++

I am writing a simple service in c++. I have copied the example on
http://www.codeproject.com/Articles/499465/Simple-Windows-Service-in-Cplusplus
verbatim, and everything works fine. Now I needed to add my code for the working thread. I add all of my files to the project, and at this point I still have the exact code from the link, so my project isn't really even using the other cpp/h files I just added. I try to start the service, and boom "cannot start in a timely fashion".
I have tried commenting out of the method definitions of the cpp files I have added, and I've figured out that any method that uses a function from the fastcgi libraries
(found here : http://www.fastcgi.com/drupal/)
causes the service not to start. If I comment out every method uses the fastcgi library, the service will start (but I kind of need those).
Is there any way I can figure out why the use of these libraries are causing the windows service I'm making not to start? (everything works fine as a console application)
Thanks

Related

How to embed python into C++ aplication and then deploy/release?

I am currently working on a C++ gui application. The application uses the Python/C API to call some python scripts. The scripts are located in the solution directory, and I call them by simply providing the path. This is currently working fine while debugging the application or even running the generated .exe file, but I am wondering how this could work if I want to release and distribute the application onto a different computer for someone to use. How can these scripts be deployed with the application?
I also have a .ttf font file with the same situation. How can this resource file be deployed with the application?
In other words, I want to deploy/release a C++ application with the scripts and resource files.
FYI: the C++ application is a Visual Studio project.
Thanks for the help in advance, and let me know if any more information is needed!
Update:
I just wanted to clear up the way my project is working currently:
PyObject* pArgs = PyTuple_New(5); // I setup the arguments the python function needs
PyImport_ImportModule("requests"); // imports...
// make python call
PyObject* pResult = PyObject_CallObject(pFunc, pArgs);
So this is (for the most part) how I call the scripts with the C++ source code. The scripts are located in a folder that is located in the solution directory.
I hope this explains my problem a little better.
Update:
Just another little update... Using some answers to other similar questions got me to the following point:
I need to obtain a python library, compile and link it with my C++ application, and then bundle the dependencies with the application (How to distribute C++ application which calls Python?)
So I guess my question is now shifting to how I would be able to get this done. What are the specific steps to do this? I also got a link (https://docs.python.org/3.5/using/windows.html#embedded-distribution) to an embedded distribution of a python environment (maybe this should somehow be used?). Also, I am able to statically link python into the application. I just don't know how to bundle and deploy the scripts I created and use in the application.
PyImport_ImportModule("requests")
The parameter is "requests".
Put the py file aside exe file when distributing.
So, you need to make sure that the C++ application can still access the python libraries when its released and those libraries/dependencies arent necessarily available on other systems.
You'll need to, like another commenter suggested, use one of the importing modules utilities, like PyImport_ImportModule("library name").
You can see these utilities here: https://docs.python.org/3/c-api/import.html
You'll also need to either
Put the libraries that you want with the exe (in the same directory) or
put them in the system environment path ( which is probably less straightforward).
Hope that helps and that I understood you're question correctly.

Deployment of Qt app when sources change frequently

I'm currently working on a GUI app that is supposed to decrypt some data and print it on the screen, on Windows and Qt (C++) based. The code works fine and I now have to distribute it.
However, the format of the data to decipher can (and will) evolve, and is described on headers (.h) and sources (.c). Therefore, when this happens, I just have to change these files to the last version, the compilation goes fine and the program runs smoothly. It's a simple drag&drop of the new files in my source folder, really.
I am aware of how to deploy a .exe (with the correct dll and so forth), but I don't think it would work in this case. I briefly looked at how to create installers but i'm not sure that this is the right way to handle the situation (http://doc.qt.io/qtinstallerframework/ifw-creating-installers.html).
How could I distribute this code so that people that want to use it can just change the sources, run a script, and the .exe is generated, even with a computer that does not have Qt ? (but probably mingw32 and only on Windows)
Thanks in advance for your help !
From my understanding, you should include dll's and if the format of the data changes, you can just update and maintain your dll's.
Build your project in release mode and then use QTWinDeploy to finalize the build of the project with all the dependencys the projects require for users without QT.
This is how I maintain and distribute a project similar to yours.
Otherwise, I would recommend looking at self-updating programs.

DLL locked - Visual Studio 2010 C++

I’m currently logged onto a machine and my current problem involves a custom build step that has trouble copying a .dll to the Bin directory because Windows says it cannot access the file because it’s currently being used by another process.
I’m able to reproduce this on several other projects. The sequence of events is that I build a release successfully, do some test, checkout another SHA when doing a git bisect, and attempt to build a release from that SHA without doing a git clean -xfd (intentionally, because I’m trying to cache as much reusable data as possible). The weird thing is that I tried to use Process Explorer (procexp) and tasklist /m <locked_dll.dll> to search for whatever is holding onto this dll, and am unable to find anything holding onto the dll. I’m on a non-admin account, and I’m not sure if that is causing Windows to hide certain processes from me. Rebooting the machine helps, but that’s not an acceptable solution since I’m trying to automate things. I’m able to delete the .dll, and when I try to build the project in VS, it’ll complain that it still can’t access the dll when trying to copy it over to the Bin folder. Any ideas? I’m going to keep researching the issue, but as of right now, I’m sort of stumped.
EDIT:
This seems to be a duplicate question (Error: Cannot access file bin/Debug/... because it is being used by another process), but I'll leave this open to see if anyone has found anything new related to the topic.
I've seen this problem in VS 2010 with a large .Net solution with multiple projects in it. Every case I've seen so far pertains to have one project with dependency DLLs that another project also uses, and that other project also uses the first project as a reference, and also uses the same dependency DLLs that happen to be a different version from the first project.
To describe it a different way:
Project A depends on v1 of DLL A
Project B depends on project A and v2 of DLL A
Both project A and B are in the same solution
The solution is to use the same version of DLL A. I usually run into this when upgrading to a new version of SQLite, and I forget to update the dependency in all of my projects.
After talking with a few coworkers, I found the solution to my problem. procexp and tasklist did not see which process was locking the dll because there was no process locking the dll on that particular machine.
I have a hardware configuration where machine A (a host PC) is connected to machine B (acts as a client that retrieves instructions from machine A) using a network switch. machine B runs the same binaries that link to the same dll's. Thus, obviously, running procexp or tasklist on machine A will not see anything locking the dll's because machine B is the culprit.

C++ ASIO driver setup

I ask you for help with the setup of ASIO sdk. I would like to use it to connect some external devices to my system but before that I am struggling to even join ASIO to my programme.
I've downloaded ASIO 2.3 from there:
http://www.steinberg.net/en/company/developers.html
and unfortunately C++ isn't my strongest point. SDK contains few folders (is folder named "Common" having every file needed?), there is no *.lib file only *.cpp and *.h files.
I don't know which files are necessary so the SDK is installed completely.
I was thinking about merging everything into one library but I don't know which files are important for SDK...
Can you give me any hints how can I add files to my program so I can start using ASIO functions in my code?
Sadly I haven't documented my ordeal last year. However, here's some pointers:
How to begin building a VSTi Plugin?
Setting up VST Steinberg SDK on Windows
Build a minimal VST3 host in C++
I admit that's basically cherry-picking the list of SO results for "steinberg", but at least the first 2 seem relevant.

Packaging a modified Qt class

Heads up, this is going to be confusing:
I customized 9 files from Qt5.2: qquicktextdocument.cpp qquicktextdocument.h qquicktextedit.cpp qquicktextedit_p.h qquicktextedit_p_p.h qquicktextnode.cpp qquicktextnodeengine.cpp qquicktextnodeengine_p.h qquicktextnode_p.h
Each file is simply prefixed with a letter and still inside /qtdeclarative/src/quick/items/. I am 100% happy with the modifications I made being put under GPL etc. I somewhat want my end application (discussed below) to be Apache or MIT, but, I'm flexible.
My modifications work fine. When I modify a few additional files I am able to compile them along with the rest of Qt (at the same time, using the same make command). But these modifications are going into another Qt application that I am making which I want other people to be able to use, and requiring general consumers to have a custom compiled version of Qt would be obviously absurd.
I want to package/compile/do something, that will enable me to include the modifications in my final project as a shared library, or something.
As a web developer writing C++ and Qt, I am very confused about linking shared libraries, header files, etc.
To recap, I modified Qt 5.2 and made a custom compilation of it for an application I am building, and I want people to be able to run that application without having to have a custom compilation of Qt. I need a way to decouple my Qt modifications from Qt.
I realize this might be a big topic, I'm not expecting a step by step guide, just some general guidance. So far I have tried compiling my modified files as a library, then including that library in my actual project, but I am getting undefined references and missing files all over the place. (I don't know if I did anything right)
I am also currently looking at subclassing the classes I want but I'm unsure about this. It might require copy pasting some code, which could have licensing issues?
end goal: be able to have a wavy underline (in qml) for incorrectly spelt words.
Thank You.
My 5 cents.
If your changes can be useful (in general) to other people you can try to push them to upstream via codereview.
If you want your application to run only in windows everything become obvious: in windows it is normal to provide your application with shared libraries (to avoid DLL HELL). Btw, have you heard about static linking?
Qt has some plugin mechanism. You can compile your code into shared object (dynamic library) and install it with your application. For example, QML FolderListModel do this. You can look at code in $qt5_src/qtdeclarative/src/imports/folderlistmodel.