How can I link winpcap in Code Blocks? - c++

Id like to know the process to link the Wincap library and use it in my c++ project im developing in Code Blocks.

After struggling to do this myself I figured that I should post my solution here.
You will need to download the developer version of WinPCap and unzip it somewhere, lets say "C:\WpdPack_4_1_2".
In Code::Blocks, you need to add the "Include" sub directory to the search directories. To do this, go to settings->compiler and click on the "Search directories" tab. For the "Compiler" "Linker" and "Resource compiler" tabs you need to add the search path. Using the location above as an example, it would be C:\WpdPack_4_1_2\WpdPack\Include.
Once these have been added, click "OK" to return to the main screen.
Then, you need to add the library file to your project build settings. To do this, right click on your bolded project name on the left side and choose "Build options". Under the "Linker settings" tab add the path to the "libwpcap.a" file.
For example, it would be C:\WpdPack_4_1_2\WpdPack\Lib\libwpcap.a.
After I did this, the example programs compiled fine. Make sure to add the #include "pcap.h" in your program to use the library.

Related

create dll out of yaml-cpp source code

Newbie to windows. I need to use yaml-cpp library in a project, but I can't seem to compile it in windows. I tried everything (everhthing!) I could find but no place have the full answer, just tips for the process. but those tips don't help so much.
I did create shared lib in Ubuntu but can't create dll in windows.
can someone give the full explanation to get dll from source code?
(I also be grateful for explanation of how use the dll with it's includes).
Working with visual studio 2015.
So finally I got it.
for linux users - use cmake. for windows users - you can but I really don't recommend it unless you need cross compiling. Use visual studio: (explained for VS 2017)
First create new project with existing code.
The folder you pick should be "src" (in case of cpp-yaml).
When creating the project you need to choose type of project (exe, dynamic or static library), so choose dynamic library to create .dll or static to create .lib.
After creating your project go to your project properties, go to c/c++ tab --> General --> "additional include directories", and add your path to the headers folder ("include"). Do not add "cpp-yaml" inside the include folder, only "include".
Now build. In the console you can see where the library was created.
To use it, in case you made static library 4 things need to be done:
add to your project "#include cpp-yaml/yaml.h"
in properties:
in tab "c/c++" --> General --> "additional include directories", add the include folder path. (as before)
in tab "Linker" -->Input, add to the "Additional dependencies" your lib name (followed by semi-colon)
in tab "Linker" --> General, add to "additional library directories" the path to your lib.

Link External Library in Xcode C++ Project

I've found answers to this question, but they don't work for me. I'm trying to build a C++ project in Xcode that uses external libraries from ffmpeg and openCV, and I can't figure out how to link them. As recommended, I go the "Build Phases" screen, and there's a place for "Link Binary with Libraries." One of the libraries I need to link with is at /usr/local/lib/libavutil.a. When I try to add a library, a list box pops up showing two folders: "OS X 10.11" and "Developer Frameworks". The library I need is not in either of these folders. I tried clicking on "Add Other" and a file chooser dialog comes up, but if I type "/usr/local/lib/libavutil.a" in the search box, the dialog doesn't accept it.
I've found that typing '-lswcale -lavcodec -lavdecice' etc. on the "Other linker flags" line in "Build Settings" works, but it's not what I hoped for. I was hoping to get a file chooser dialog, where I could simply click on the libraries I want to use.
Is there a way to accomplish what I want?
If I understand correctly what you are asking, you simply want to "set" the file chooser dialog at the right place, right?
If so, you just have to press Cmd + Alt + G once you are in the file chooser dialog, after clicking on "Add Other..." in the "Link Binary with Libraries" menu. A "Go to the folder:" dialog comes up, and there you can type the fullpath to the file or the folder you are looking for.
Hope that helped!
Since nobody else has provided a working answer, I am documenting that the only only thing I have found that works it to set the search paths for the libraries under "Library Search Paths" and then to add a -l flag for each library in the "Other Linker Flags" section, just as you would on the command line command line:
According to this, you can try:
1) Open the left panel, goto "ProjectName", Targets, Build phases,
Link binary with libraries and select your library.
2) Open the left panel, goto "ProjectName", Project, Header Search
Paths, write the path where the headers of your library are (the .h
files, usually in /usr/local/include).
3) Open the left panel, goto "ProjectName", Project, Library Search
Paths, write the path where your libraries are (the .a or .dylib
files, usually in /usr/local/lib)
I hope you can confirm that this work for Xcode7.
On Step 1) You can also:
Under "Link Binary With Libraries", click on the plus button.
Click "Add Other..." (this is a 3rd party library).
Choose the filename (/usr/local/lib/libavutil.a).
P.S., I can't flag as a Dup, because that was not an acepted answer

Eclipse CDT add existing source without copying

I have a C++ project proj1 with some source files in, however I would like to also use some of the source files I have in another project proj2. proj1 and proj2 are both subdirs of a directory my_projects. I don't want eclipse to copy the files as I want to ensure I have only one copy to edit. This is like the "add existing item" option of MS Visual Studio.
The end result I'm aiming for is to be able to create makefiles for both proj1 and proj2, zip up the two directories together and send them to coworkers so they can build the two projects themselves using make.
Is this possible in Eclipse? I've searched and haven't found the solution.
Phil
If you have proj2 open in Eclipse right click on the project and choose Import... and then select General > FileSystem and hit next. In the top window choose the directory in proj1 that contains the resources you want to link. After selecting the files you want to link in the top window hit the Advanced button to open up a submenu and select Create Links in Workspace as shown in this screenshot:
This question addresses setting up a Makefile with relative instead of absolute paths: Getting Eclipse CDT to use relative include paths in generated Makefiles
I looked forever for a solution to this, and I finally found it. Right click on the project and select Build Settings. Under the Build header on the left click "Settings". Then under the "Tool Settings" tab click "Directories" under the compiler header. Then click the add button at the top. If the desired files are in another project in the same workspace click the workspace button and then navigate to the exact folder where the files are. Once you have done this voila! you should be able to build the project!

how to link the fmod library in visual studio

I am just a beginner at windows programming and was reading a tutorial about it.
It said something about resources for menu creation.
I am working in visual studio 2010 and would like to know how to create these resources (the turorial said something about adding them to the compiler which i could not understand) for simple things like menu bar creation.
Please help me.(Please keep in mind that I am a beginner therfore explain in detail if possible.)
To actually use the additional functionality you have to include the header and specify the directory where it is contained so the project can find the file
right click on project->properties
C\C++->general tab
the top element is Additional Include Directories - click the down arrow and specify the path to the header file
For your application to use the functionality you have to link with the lib
right click on project->properties
Linker->general tab
The 9th element from the top is Additional Lib Directories
& specify the path to the accompanying lib file
NOTE that the dll that corresponds (if dynamically linked) must be either in the system path or in the working directory of your application
under the linker -> input tab
you'll want to specify the name of the .lib file to load (the same as the file contained within the path you specify to link with with)
Alternatively - if the you'd like to make a project depend on another project within the same solution
right click the project->properties
the top tab is Common Properties
within that tab click the button "Add New Reference" and select the project

Importing third-party library source files into Eclipse CDT

I've got a project set up very nicely with eclipse-cdt. I'm not building from eclipse, but the indexer works and all my makefile settings were picked up, including third party libraries headers.
What I would like, however, is to be able to view the actual source of those libraries - say, if I want to see some code in Qt or libc I'd like to be able to CTRL+click into the method from the relevant header file. You can do this in the java version of eclipse, whenever you are missing a source file, you have an option of "attaching source". I've looked everywhere with CDT and can't find a solution. I don't want to build these third party libs, I just want to be able to click-through to their source code, not only to their headers.
Does anyone know how to do this (am I missing something obvious)?
Ok, found the answer.
In the Project's Properties window, under "C/C++ General" there is a tab called "Source Location", your project's folder should be listed there. Click on "Link Folder", mark the "Link to Folder in the file system" and use "Browse" to find the folder where all he library's source code is.