How add shared-library to my library project in QT - linux

May i load external library in my library project? If yes. How i can do this.
With Qlibrary? or typically include in pro file LIBS += -L /lib -lmylib and add *.h file to project?
Sorry for my English))))

Just go to your respective Qt .pro file in Qt Creator IDE itself, and right click on empty area and choose "Add Library", Select external Library and click next, now click on browse in front of include path text box and choose the .lib file you want to include and select the platforms you want to target and now click next and finish the process. To add .h file, first copy the .h file in your project folder, and right click on the header under solution explorer, and click on add existinf file, now select your .h file and add it.

Yes you can.
If you want to use shared library just add in you application *.pro file
LIBS+=-Llibrary_location_path -llibraryName
INCLUDEPATH += library_headers_location
Check original documentation http://doc.qt.io/qt-5/third-party-libraries.html
P.S. I suppose you understand that .h files contains declaration of methods that you are going to use in your appplication, while library contains implementation of this methods

Related

Where to add the directory for .def file in Visual Studio?

How can I add to Visual Studio's linker a .def file to use for linking. I have added the .def file, but I cannot figure out how to specify the directory in which the .def file resides. Simply adding the .def file to the Visual Studio project did not help. Nor did copying the .def file to the project's source directory folder. I have also tried specifying the Visual Studio additional include directory as where the .def file resides.
It's on the Project Properties > Linker > Input page. Edit the Module Definition File field to point to your .DEF file. Be sure to do this for both the Debug and Release configurations.
(To get to Project Properties, right-click the name of your project in the Solution Explorer window, and choose the menu option Properties. The configuration setting, Debug vs. Release, is controlled by a drop-down menu at the top of the Project Properties dialog.)
What fixed this was adding the full path for the .def file in the linker properties.
Even though the documentation states:
/DEF:filename
filename
"The name of a module-definition file (.def) to be passed to the linker."
it seems that filename can in fact be a full file path.
Go to
Project -> Configuration Properties -> Linker -> Input -> Module Definition File
and try:
C:/mydeflocation/my.def
or
$(ProjectDir)/../mydeflocation/my.def
etc.

How to add external references in MonoDevelop?

I've downloaded a charting library called NPlot and I have no idea how to add it as a reference in a GTK# application I'm currently making in MonoDevelop. There is no option in the Edit References window that you could add an external reference apart from the listed ones.
How do you add an external reference in MonoDevelop?
Being fairly new to Ubuntu (consequently, to using apps), I found it quite challenging to grapple with the dilemma above. After hours of searching (almost half a day actually), I found the answer. I created this post for others who might be facing this problem too.
Before proceeding, make sure you have your dll file to add as a reference.
First, create a .pc file containing the following:
Name:
Description:
Version:
Libs: -r:<where your dll is>
Example:
Name: NPlot
Description: Creates charts.
Version: 0.9.9.2
Libs: -r:/home/xxx/Downloads/NPlot/nplot-gtk-0.9.9.2/NPlot.dll
Hat tip to this site.
Remember where you've saved your .pc file. I've saved my file in /home/xxx/Documents. Next, copy the .pc file to /usr/lib/pkgconfig. I'm not sure with other Linux distros, but Ubuntu is preventing me to directly copy paste the file to the folder, so I have to use this command on the terminal:
sudo cp <source> <destination>
Example:
sudo cp /home/xxx/Documents/NPlot.pc /usr/lib/pkgconfig
It is now included in the Edit References window.
If the reference does not show, please refer to this question.
Unzip the NPlot zip file and extract the dll you need.
In the Edit References dialog select the .Net Assembly tab.
Click the Browse button and browse to the NPlot dll file and select Open.
Click OK on the Edit References dialog.

Ignore R.java files in Find results

When I do a Find in Path (Ctrl+Shift+F), I often get results under "Usages in Generated Code" in R.java files. When I'm searching my code, I want to do just that: search my code. Not files generated by my code.
Is it possible to get the find dialog to not show any R.java files in the results? The only results I want are those under "Found Occurrences"
Thank you!
Android Studio (like its progenitor IntelliJ) allows you to define a custom scope to help you exclude intermediates files when searching.
Here are the steps I use to set this up:
Bring up Find in Path dialog (Ctrl+Shift+F on my machine).
In the Scope area, select the Custom radio button. Then tap the "..." button on the right side of the dropdown. This brings up the Scopes dialog.
Click the "+" button on the left side of the Scopes dialog, which will bring up the Add New Scope dialog. Name it "ExcludeIntermediates".
In the Pattern field, paste in the following pattern and click OK:
!file:*intermediates*/&&!file:*generated*/
This pattern excludes R.java files and other intermediates such as layout files in exploded-aar and AndroidManifest.xml copies in filtered_manifests folders.
This pattern excludes R.java files and other intermediates such as layout files in exploded-aar and AndroidManifest.xml copies in filtered_manifests folders.
ignores R.java files
ignores all *.java files generated by Android Annotations (i.e. *_.java files)
includes strings.xml, dimens.xml, styles.xml, attrs.xml, colors.xml files
includes all xml files in layout/* path
!file:*intermediates*/&&!file:*generated*/&&file:*java&&!file:R.java&&!file:*_.java||file:*strings.xml||file:*dimes.xml||file:*styles.xml||file:*attrs.xml||file:*colors.xml||file:*layout/*xml&&!file:*build/*xml
Combined from:
https://stackoverflow.com/a/32238593/1815624
&
https://stackoverflow.com/a/32680493/1815624
To search multiple modules but ignore R.java, you could use the following mask IF you don't have any other single character file names in your project:
☑ File mask(s): ??*.*
i.e. Limit results to filenames with at least 2 characters + any extension.
If you're using Android Studio, a simple way of achieving this is to set the Scope to be Directory (rather than Whole Project) and set this directory to be your src folder - since R.java appears under build/generated it won't appear in results there.
I use "custom scopes" in Android Studio to ignore R.java files. Others had described how to create/save a "shared custom scope" which can later be uploaded to a git repository. I'm just gonna share my custom scope string which:
ignores R.java files
ignores all *.java files generated by Android Annotations (i.e. *_.java files)
includes strings.xml, dimens.xml, styles.xml, attrs.xml, colors.xml files
includes all xml files in layout/* path
file:*java&&!file:R.java&&!file:*_.java||file:*strings.xml||file:*dimes.xml||file:*styles.xml||file:*attrs.xml||file:*colors.xml||file:*layout/*xml&&!file:*build/*xml
You could just avoid all the generated files from your project, as Mike Evans suggest in this tweet
You just need add a scope excluding the pattern mentioned:

Assembly code support in source insight

Has anybody tried browsing assembly language file (filename.s) in source insight?
I just added whole Linux kernel project into source insight but it does not support any of the assembly files.
When you create the project in Sourceinsight, it adds all the types of files (like *.c, *.h, *.cpp, etc) it knows. It also adds assembly files but only '.asm' and '.inc' files. To include all *.s files as assembly file in the project, You need to tell Sourceinsight to treat '.s' files as assembly files.
This can be by Document Options->Document Type -> select the x86 ASM Source File and then add on the in file filter box inside * s along with *.asm and *.inc. Once you are done with this, now you re-add all the files from root directory of the project (Project->add and remove files) and you will get the *.s files in Sourceinsight.
In The File field -> Load file -> Browse [give path]-> File Type [make it as all]
Then you will find your ".s" file open it ,
You can use it like normal files
in settings tab you should find it out.
There is an option to add support for all file types.
Method to unconditionally include all Files present in the directory (Folder) :
CREATE A NEW DOCUMENT TYPE :
Go to Options ==> Document Options ==> Document Type. Press 'Add Type' button. Create some new type called MY_Unconditional.
Set 'File Filter' for this type as, *, *.*. (* wild card indicates all the files. *.* indicates all the files all type of extension.)
Close the dialog box.
ADD ALL FILES TO PROJECT :
Go to Project ==> Add and Remove Project Files
Choose your directory
Uncheck the box, 'Show only known document types'. Now, it will show all the files in the directory.
Now, press 'Add All' button. press 'Add Tree' button also if required.

Visual C++ Include File not found

I have a project, and I added all the source files to it. I then clicked build, and it said:
fatal error C1083: Cannot open include file: 'common.h': No such file or directory
1> crc64_tablegen.c
This is rather annoying, because common.h is in my project! It's right there! I think it might be in a different directory though. Is the the reason? Should I move everything to a root directory, then add that instead? Thanx!
Where files are in the project structure makes no difference to the compiler when it is attempting to open include files. If they are in a different directory, you will need to path them appropriately.
That is, if you have this directory structure:
project/include/common.h
project/src/main.cpp
And you have this in your project:
Project
|-> common.h
|-> main.cpp
Your main file will need to do this:
#include "../include/common.h"
And not this:
#include "common.h"
You may, alternatively, define project/include as an Additional Include Directory in your project settings. This will allow you do use the second include form shown above.
Compiler doesn't know anything about project and files included in it. If .h file is in another directory, you need to add this directory to the list. For example, open Project - Properties - C++ - General - Additional Include Directories, and add $(ProjectDir)Include or something like this.
In VC++, the location of files within the project is virtual and has no link whatsoever to the actual filepaths. You may have to be more specific with #include and/or move the source files into the project directory to be found.
Try and add the path in the project settings under Additional Include Directories.
Here are the full set of steps:
Drop down the Tools menu, and select Options
In the box on the left is a list of option categories. Select "Projects and Solutions" and then the sub-category "VC++ Directories"
In the upper right hand corner is a drop-down box that selects a particular set of default directories, including "Executable files", "Include files", "Reference files", "Library files", and "Source files". Generally, you only want to add to the "Include files" or "Library files" lists. Select "Include files"
In the middle of the right hand side of the window is a list of directories. Add the include path by pressing the "New Line" button above the window, or by pressing "Ctrl-Insert". A blank entry appears for you to either type the path or navigate by clicking the "..." button. Generally the final path you want will end with a folder called "include". Enter the path now.
You're done, click OK
If you have added a .h file to an existing project and are getting the error message C1083: cannot open include file. Make sure you have it added properly to the program.
If you have #include it might not work.
Try entering #include "course.h" instead.
I have been working this problem with my project for several hours and have just now realized this error. You can also add the directory in the project properties to have it work, but when you send it to someone else to view it, they might receive the same error.
I just had the same problem in Visual Studio 2017, and found what was causing it. There is a difference between the following two includes:
#include "common.h" // Quoted form
#include <common.h> // Angle-bracket form
First include can uses the file that contains the #include to find the included header file.
Second include ignores the file that contains the #include, so if you don't have the directory of header file in Additional Include Directories it will not be found, ALTHOUGH the IntelliSense will happily jump to the header file (Ctrl+Shift+G) as if it was included like in the first case.
So, either change the #include or add the directory to Additional Include Directories.
More info at Microsoft Docs.

Resources