I have created a Dynamic Library using Qt Creator which I have included in another Qt Project but when I call functions with works with resource files for example reading the contents of a .txt in resources, it does not work.
Once I have the Build of the Dynamic Library which created the *.so, *.a and the qrc_resources.cpp files in another folder outside the library project folder, example:
Project Folder: /home/username/Qt Project/library/
Build Folder: /home/username/Qt Project/build-library/
I then copy the build files into the library project folder and from the test project (a Qt Application Project), I right click on the project -> Add Library -> External Library -> Select the .so file (from the library project folder which I just copied).
Then, after including the header files and calling a function which reads the contents of a file from the qrc resources, it does not work.
UPDATE
I used a QFile to check if the Resource File exists in which it does but I get this error: QIODevice::read (QFile, ":/file.txt"): device not open
Adding Libraries to Projects
later
I think need to create an external resource file.
So I was able to resolve the problem by using a QFile object instead of ifstream object to open and read the file.
I want to create a shared library to communicate with database. I want to use Pimple idea in my implementation, but I don't know which header files must be added to program so that Qt can find Q_DECLARE_PRIVATE and some other macros.
Is it necessary to add some command to .pro file?
I have a sketch that I am trying tin use Time.h in or DateTime.h. I have imported the libraries and they show up in the list on libraries. when I click on ether of them they just ad a blank line to my sketch. if I try to add it myself like #include then try to access part of the library I get an error telling me the item I am trying to access is not defined. I can see the Time and DateTime folders in the libraries folder. and can see them as a options in the import Library menu.
Please help.
Danny
Just remove library from
Documents\Arduino\libraries\DateTime\
and copy lib manually from zip file.
In the Arduino GUI on windows, if I click on Sketch --> Import Library, at the bottom of the menu there is a section called "Contributed".
Unfortunately, I had misclicked and added a library I did not want to that list.
How can I remove it from that list?
The help page only mentions that "If a sketch no longer needs a library, simply delete its #include statements from the top of your code" but it does not mention how to remove the library from the list of contributed libraries.
Go to your Arduino documents directory; inside you will find a directory named "Libraries". The imported library directory will be there. Just delete it and restart the Arduino app.
Your Arduino library folder should look like this (on Windows):
My Documents\Arduino\libraries\ArduinoParty\ArduinoParty.cpp
My Documents\Arduino\libraries\ArduinoParty\ArduinoParty.h
My Documents\Arduino\libraries\ArduinoParty\examples
....
or like this (on Mac and Linux):
Documents/Arduino/libraries/ArduinoParty/ArduinoParty.cpp
Documents/Arduino/libraries/ArduinoParty/ArduinoParty.h
Documents/Arduino/libraries/ArduinoParty/examples
The only issue with unused libraries is the trivial amount of disk space they use. They aren't loaded automatically so don't take up any application memory of the Arduino IDE.
Quote from official documentation as of August 2013:
User-created libraries as of version 0017 go in a subdirectory of your default sketch directory. For example, on OSX, the new directory would be ~/Documents/Arduino/libraries/. On Windows, it would be My Documents\Arduino\libraries\. To add your own library, create a new directory in the libraries directory with the name of your library. The folder should contain a C or C++ file with your code and a header file with your function and variable declarations. It will then appear in the Sketch | Import Library menu in the Arduino IDE.
To remove a library, stop the Arduino IDE and remove the library directory from the aforementioned location.
The answer is only valid if you have not changed the "Sketchbook Location" field in Preferences. So, first, you need to open the Arduino IDE and go to the menu
"File -> Preferences"
In the dialog, look at the field "Sketchbook Location" and open the corresponding folder.
The "libraries" folder in inside.
I have found that from version 1.8.4 on, the libraries can be found in ~/Arduino/Libraries. Hope this helps anyone else.
I had to look for them in C:\Users\Dell\AppData\Local\Arduino15\
I had to take help from the "date created" and "date modified" attributes to identify which libraries to delete.
But the names still show in the IDE... But it is something I can live with for now.
For others who are looking to remove a built-in library, the route is to get into PackageContents -> Java -> libraries.
BUT : IT MAKES NO SENSE TO ELIMINATE LIBRARIES inside the app, they don't take space, don't have any influence on performance, and if you don't know what you are doing, you can harm the program.
I did it because Arduino told me about libraries to update, showing then a board I don't have, and when saying ok it wanted to install a lot of new dependencies - I just felt forced to something I don't want, so I deinstalled that board.
In Elegoo Super Starter Kit, Part 2, Lesson 2.12, IR Receiver Module, I hit the problem that the lesson's IRremote library has a hard conflict with the built-in Arduino RobotIRremote library. I am using the Win10 IDE App, and it was non-trivial to "move the RobotIRremote" folder like the pre-Win10 instructions said. The built-in Libraries are saved at a path like: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries
You won't be able to see WindowsApps unless you show hidden files, and you can't do anything in that folder structure until you are the owner. Carefully follow these directions to make that happen: https://www.youtube.com/watch?v=PmrOzBDZTzw
After hours of frustration, the process above finally resulted in success for me. Elegoo gets an F+ for modern instructions on this lesson.
as of 1.8.X IDE
C:\Users***\Documents\Arduino\Libraries\
My solution is low-tech but effective so I want to share:
create a folder for disabled libraries next to libraries
move libraries here to disable, swap back in to re-enable
I have 2 Qt projects that I've made. One builds a library the other builds a GUI that uses that library. My project with the library includes a bunch of shaders that I've made. Within my GUI I want to reference the path to these shaders. My approach is to have a static function in my library called getLibraryPath() that returns a QString referencing the path on my file system to the library.
I've tried using QDir::currentPath() and QApplication::applicationFilePath() and other similar functions that return paths but they all return paths referencing my GUI's path, not the library's path even though the function to get the path is located inside the library.
Within my GUI I try to reference a shader by doing: Shader->addShaderFromSourceFile(QGLShader::Vertex, MyExternalLib::getLibraryPath() + "/shaders/MyVertexShader.vs");
A library is just a bunch of code. It has no notion of having its own path. The normal way of doing what you intend to is:
If the library is a separately installed product -- set a registry entry in the installer, and check it at runtime. This will be platform specific, unless the library is written in Qt -- then you can use QSettings, but make sure that you set your company name, application, etc. appropriately as it's not done by QApplication for you anymore.
If the library is installed as a part of your application, in the same folder tree: use QCoreApplication::applicationDirPath() and add a relative path between the application executable and the files you want to this path.
I was able to solve this by adding the files I want to reference to a qrc file within my library project. By doing this, I could then reference the qrc path and the files inside of them easily.