C++ :: Reinitialize Dynamic / Share Library?
Jan 23, 2013
I am getting some problem in a dynamic/share library I am using with my code. Restarting my application solves the problem.
tell me any safe way to reinitialize kind of mechanism for dynamic loaded libraries with minimum code changes in my application?
View 3 Replies
ADVERTISEMENT
Apr 17, 2013
I am porting an application from Linux to Windows. Since it is a GTK app most of the stuff works; I have to touch a little here and there. One problem though I cannot find the solution as it seems. The application uses a plugin system for easy expandable functionality. The interface to the plugin is very simple: an init function, a worker function, and a deinit function. The plugins shall have access to the main applicationsymbols (functions global variables). I cannot find a working (and feasible) way under Windows to make the linking work. I always get "undefined reference" errors for symbols which exist in the application. I am using MinGW 4.6.2. I made a stripped down demo application to be able to better (and faster) test the principle. I am using the dlfcn-win32 project from Ramiro Polla [URL]... for the dynamic loading stuff and it works like a charm.
Here is the project:
plugintest.tar.gz
plugintest.zip
It tried a number of commandline options to the linker for the application (--export-all-symbols, --export-dynamic, -rdynamic (apparently not supported in MinGW)) as well as for the shared objects (--allow-shlib-undefined, --enable-auto-import, --enable-runtime-pseudo-reloc).
As you can see in the provided makefile under Linux it is just "-shared" for the .so. Under Mac OS X (Darwin) it is "-bundle -bundle_loader <app name>".
Either it is a different configuration / environment or I must have overlooked something. How to do this and if it is even possible in Windows?
Here is a .zip archive of the dlfcn stuff with modified makefile, which works on the cmd.exe command prompt; MSYS is not required. Just adjust the MinGW installation path in config.mak and type 'make" and 'make install'. dlfcn-win32-r19.zip
View 9 Replies
View Related
Apr 2, 2014
I am wondering how to share a variable in 3 classes. For example:
variable class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
[Code] ...
class that edits the variable:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
[code]......
The actual program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
[code]......
What should happen when this runs is this:
Variable changed in program: 0
Same variable changed in a different class: 1
Instead, this happens:
Variable changed in program: 0
Same variable changed in a different class: 0
View 7 Replies
View Related
Mar 22, 2013
Code:
#ifndef CANDIES_H
#define CANDIES_H
#include <iostream>
#include <fstream>
#include <Global.h>
class Candies
[Code]...
Code:
#include "Candies.h"
#include <Windows.h>
#include <iostream>
#include <fstream>
#include <sstream>
[Code]...
When I tested it, the file name in getName() outputted the right file name. However the file name in loadName() does not print out anything in the console window.
I want it to be so that the strings in [I]name_addTXT.c_str() in both functions are equal.
View 4 Replies
View Related
Mar 16, 2012
Here is what I did,
Code:
// A.h
const int salary = 1000000;
// B.h
extern const int salary = 1000000;
But I still got multi-definition errors. How should I fix it?
View 6 Replies
View Related
Nov 24, 2013
In general, my problem is that I've been trying to reorganize the project I and my group are working on into separate project files. Everything was working perfectly fine before, but now I'm facing the wrath of undefined reference errors when I try to call my DLL functions.
I have them declared and included in the central header file here :
Code:
/* DLL functions */
typedef void ( * t_wait )( int milliseconds, const int frames_per_seconds );
typedef clock_t ( * ft_timer )( int command, t_timer * timer_object ); /* clock_t is usually defined as long */
typedef void ( * t_SDL_errorexit )( const char * message );
typedef SDL_Surface * ( * t_load_image )( char * image_path, unsigned is_transparent );
[Code]...
Then I have them imported here :
Code:
/* ******************************************************** */
/* ********* win_error( char *, bool ) ********* */
/* ******************************************************** */
/* - Displays a GUI for a windows specific error message, */
/* pass true to it to have it exit the program, pass false */
/* to have it continue */
/* ******************************************************** */
extern void win_error( char * message, bool is_exit )
{
/* Note : win_error uses the Win32 Api */
/* ********************************** */
char buffer[BUFSIZ] = { 0 }; /*
[code]...
This doesn't work, as my compiler sees it that I am trying to call invalid functions, whereas I have made sure to import the functions before calling. Obviously my compiler can't tell that, and is trying to protect me from calling them.
The source files are compiled as C++, but I'm using C-style code instead of true C++ code.
Obviously I'm using Windows style DLL linking, but if the only ways to share imported functions are non-standard, only post ways that will work on as low as Windows XP.
I have tried to statically link them before, but that led to a problem that I posted a while back. Which led me to dynamically linking, which was problem-free until I separated my code into separate files.
View 13 Replies
View Related
Dec 9, 2013
this last few days I've been coding this one particular file
Hero.cpp
namespace Hero {
namespace {
// all data here
}
}
then the code grew a bit to about 700 line
Then now I want to implement hero skill system It needs the access to data inside the unnamed namespace where I put just about everything.. but it's unnamed namespace, it's only valid within one file and I should hide all that data from Hero interface in Hero.h How should I do this ?
View 12 Replies
View Related
Jul 2, 2014
Basically i'm willing to create an application which could share Video,Mp3 Over the internet to my friends.
For suppose I'm hosting file on my PC, and i want to share "D" Drive to my friends but they aren't connected to my network locally. i want to share movies over the internet using a host and client application in c#.net.
the purpose of this application is very clear that that i want to share movies over the internet and they have to be able to watch movies on their PCs Except running my PC remotely.
View 8 Replies
View Related
Dec 8, 2014
I want to create 2 different easy processes in C++ 1st and then i wanted to share data between these 2 processes.
View 7 Replies
View Related
Jan 17, 2014
I've been reading about libraries; How to make them, how to use them, the different types of libraries, etc..
When using a shared library, does the program require that library to be installed on the computer after the program has been compiled into an .exe?
Ie.. if somebody downloaded a "Helloworld.exe" that I had compiled on my computer using a shared library (that wasn't part of a standard operating system), would they also need that shared library on their computer for the program to run without errors?
and for Static Libraries, when I compile a program using a static library, does it include in the final binary only the functions of the library that are actually used, or does the compiler add in the entire library?
View 8 Replies
View Related
Jan 4, 2013
I'm writing a program in which I have to use a matrix to represent a file in code. because it's a file, the size of the matrix is undefined, and therefore the matrix has to be dynamic. I found out that my compiler doesn't like dynamic multidimensional arrays, so I was thinking of this matrix as a dynamic (monodimensional) array of other dynamic (monodimensional) arrays. My program (and thus this example) uses unsigned chars.
unsigned char variable=something;
unsigned char**matrix=new unsigned char*[lenghtOfMainArray];
for(int rowNumber=0;rowNumber<lenghtOfArray;rowNumber++)
{
[Code].....
View 2 Replies
View Related
Oct 7, 2014
i'm implementing a playerclass for a game.. in the game there are multiple player types, weapons ect.. i just wanted to turn my players weapons into a dynamically allocated c_str. once i added my: Destructor, Copy Constructor and Overloaded Assignment Operator. My initial values became corrupted and i cannot fix them.
Player2.cpp
#include <string.h>
#include <iostream>
#include <cstdlib>
#include <iostream>
#include "player2.h"
#include "dice.h"
#include "gamespace.h"
[code]....
View 1 Replies
View Related
Dec 11, 2014
I wanted to share the value of a variable from Sender Program to Receive after program and want to calculate difference between send and receive. After studying Header file concept I program following three.
Now I am struck. How to to compile? I link all these file. I used following method:
Code:
gcc Sender.c -o Sender Sender.h
gcc Receiver.c -o Receiver Student.h
Then I run Sender and after that Receiver.I per my knowledge, Receiver should give difference but it gives error :
Code:
Receiver.c: In function "main":
Receiver.c:10:42: error: "Send" undeclared (first use in this function)
printf(" Total Receive is %d
",Receive-Send);
Code:
Sender.c
#include <stdio.h>
int Send ;
void main(){
[Code] ....
View 2 Replies
View Related
Feb 19, 2013
How do you install the gmp library.How do you use it?
View 11 Replies
View Related
May 11, 2013
I'm trying out the gmp library by building a simple pi calculation program (original, I know!). On a million digits of Pi I've debugged the program and seem to have about a megabyte too much of memory at the end of the program (I start with around 250k before any allocation begins and end at around 1200).
int main(int argc, char *argv[]) {
//set a//
int digitsofpi =1000000;
mpf_set_default_prec(log2(10) *digitsofpi );
mpf_t a;
mpf_init (a);
mpf_set_ui (a,1);
[code].....
View 2 Replies
View Related
Jul 11, 2013
I would like to set the bullet library to GCC. I downloaded source code of bullet but i don't know how to set that.
View 6 Replies
View Related
May 9, 2013
I have been trying to find a way around the following:
I am using a library functor to solve the root of a non linear equation. It passes two doubles and the name of a function that contains the equation to be solved.
Its xtor and operator are
RootFind(double tL,double tR,double (*fn)(double t));
void operator()(double tL,doubleR,double (*fn)(double t));
I want to be able to send another variable to function fn; I don't know what the value of the variable will be ahead of time.
How do I get the library functor to take an extra variable in the function passed?
View 1 Replies
View Related
Nov 5, 2014
I use the library opensteer, but I do not know where you should start.
Opensteer is a library written in C ++. My problem is figuring out whether to create a blank project in visual studio and import the library or directly import the library.
View 2 Replies
View Related
Jan 29, 2014
I'm attempting to write a little UDP socket library in c++ on linux so a user can just create a new instance of a UDPSocket class, specify destination ip and port, and just connect. Then the user should be able to call send() or receive() in any order they want.. and here I encounter a little problem..
Most of the tutorials for udp socket sending out there include a bind() call when you create your "server" that is supposed to receive data, but the code that send data does not need one. Because I also want my library to support unicast/broadcast/multicast, I have read that I need to set the socket option SO_REUSEADDR on my sockets (since multiple sockets will need to be connected to same destination IP/port for broadcast/multicast)
My question is.. do I need to create 2 socket handles per "UDPSocke in order to make this work? One for sending and one for receiving data? In my code when I try to work with only 1 socket, it is only able to receive stuff from itself on unicast.. Or should I just remove the SO_REUSEADDR when in unicast mode, then try to bind with both sockets, accept that the bind will only work on the 1st socket, and take it from there?
View 1 Replies
View Related
Dec 28, 2014
Any common and good library for plots ? (2D and 3D)
View 1 Replies
View Related
Jan 27, 2015
I want to create a C library function that i can directly call in my code from any .c file having main program.following are codes...code of library function "foo.c"
Code:
#include "foo.h"
int foo(int x) /* Function definition */ {
return x + 5;
} header file "foo.h"
Code:
#ifndef FOO_H_ /* Include guard */
#define FOO_H_
int foo(int x); /* An example function declaration */
}
[code]....
to use this i have to compile the file in below manner...
Code: gcc -o my_app main.c foo.c
My concern here is that i want to compile the main.c and use function without compiling foo.c with i.e.
Code: gcc -o my_app main.c
any user of this function should only compile his program and should be able to use the function, the foo.c file should remain hidden from him
my system is Linux 2.6.18-308.4.1.el5 #1 SMP Wed Mar 28 01:54:56 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
View 9 Replies
View Related
Oct 7, 2014
I am trying to refresh my memory here as I did some studies many years ago but the results elude me.Also todays c/c++ compilers may have better optimizations.Say I have a static library that includes three obj modules.Each of these object modules has a number of functions. These functions do not reference any other functions within the obj module.My main app links this library but only references one function from each of the object modules.
Question: Are the complete contents of each module linked into my main app or are todays linkers smart enough to just link the functions used?
View 4 Replies
View Related
Jan 29, 2015
What's the best performance library for loading images in PNG?
View 5 Replies
View Related
Mar 8, 2013
I am in try to use PlPlot library (for plotting) in C with code::blocks IDE (ver 10.05) on windows-7 plateform. I downloaded "plplot-5.9.9.tar" and unzipped it. In documentation it is not very clear to me (I am not expert in using third party lib.), how this library can be used with code::blocks i.e. where I have to save the lib, what should be added in compiler and debugger settings etc. It also seems from document that "makefile" (linux type!!) is necessary for Windows also? I am also unaware of MSYS makefile generator (given on Wiki page) on windows?
View 2 Replies
View Related
Feb 2, 2013
I'm completely new to C, and I don't know how to create a library using Xcode.
View 5 Replies
View Related
Feb 5, 2015
I have a problem with compiling the Allegro5 library:
"Cannot find allegro-5.0.10- monolith.mt"
source:
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <cmath>
int main() {
al_init();
al_init_primitives_addon();
al_install_keyboard();
ALLEGRO_KEYBOARD_STATE klawiatura;
[Code] ....
View 1 Replies
View Related