C++ :: Shared Library Export And Calling Convention?

Aug 13, 2013

I want to create a simple shared library that exports a simple C API, just like llvm-clang.

The library should be compilable with any compiler and be used by a variety of languages, again just like clang.

For visual studio that is:

Code:
extern "C" __declspec(dllexport) void __cdecl myfunc(int arg);

The __cdecl is the issue here: i cannot seem to find a compiler agnostic way of specifying the use of cdecl.

So i went to see how my favorite C API libraries (ie clang) handle it.

none of them specify a calling convention at all!

Code:
#define CINDEX_LINKAGE __declspec(dllexport)
CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); //exported

how does that work? How does the compiler know to use __cdecl and how would i link to it dynamically without that knowledge?

View 1 Replies


ADVERTISEMENT

C/C++ :: How To Change Calling Convention

Nov 20, 2012

As C supports _cdecl calling convention if I want to change it to _stdcall then what should I have to do?

View 3 Replies View Related

C++ :: Shared Library Vs Static Library?

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

C++ :: Shared Library Throws Exception But Not Caught

Jan 10, 2013

A test program of mine loads a shared library (.so file). A function call in the shared library throws an exception that I am trying to catch in the main function of my test program. (I know that exception is being thrown for sure, I wrote the library to do that.)

However in the main program, the exception is not being caught. The flow of program goes past the catch block like no error has occurred. I am using g++ and I load the shared file using -l option. Only trying to load the program statically I got the following error:

/usr/bin/ld: cannot find -lmy-shared-library
collect2: ld returned 1 exit status

Why the exception is not getting caught.

View 9 Replies View Related

C :: How To Create A Shared Library From Source Code In Autopy

Jan 22, 2013

I'm trying to find a C library for automating mouse clicks and keystrokes, something like the Python package AutoPy would be ideal.

Might have heard of Auto-it [URL] ...., which automates GUIs in Windows. Something like that would also be good, but my main OS is Linux.

I'm not sure whether it would be possible to create a shared library from the C source code in autopy.

View 4 Replies View Related

C :: Ubuntu Build - Test Program To See If Shared Library Properly Built

May 22, 2013

I have created a shared object in Ubuntu (libMYLIB.so). I am now trying to compile a simple test program (testmylib.c) to see if the shared object is properly built. I am getting an error that the build cannot find the shared object. My build command is:

gcc -lm -l /dir/mylib -lMYLIB.so -o testmylib testmylib.c

where /dir/mylib is where my source and libMYLIB.so reside.

What am I doing wrong?

View 9 Replies View Related

C++ ::  typedef As Data Type For Specialized Template Function In Class From Shared Library

Jul 19, 2013

I have a class "Result" with a single template function Set(const std::string& arName, T& val) and a specialization of this function Set<Real>(const std::string& arName, Real& val) where Real is a typedef for double. The class is in a shared library and I use it in my main program. If I do result->Set<GLOBAL::Real>("U", 100.0); the wrong template function is called!

I check this by the output with std::cout.

Maybe it's a problem with the typedef.

If I link the object file of the Result class directly to my main program (no shared library), it works.

typedefs.hpp:
namespace GLOBAL {
typedef double Real;
} results.hpp
#include <iostream>

[Code] ....

View 3 Replies View Related

C++ :: Calling A Function Of A Library

Apr 6, 2012

I have a code like this below in /root_project/main.cpp:

Code:
#include "theoraplayer/TheoraVideoClip.h"
unsigned int tex_id;
TheoraVideoManager* mgr;
TheoraVideoClip* clip;
std::string window_name="glut_player";
bool started=1;

[Code] ....

and the TheoraVideoClip.h file is in /root_project/include/theoraplayer/.

Inside of TheoraVideoClip.h there is this:

Code: TheoraVideoFrame* getNextFrame();

And when I try to compile using g++ -o app main.cpp -lGL -lglut -lGLU -ltheora -ltheoradec -ltheoraenc I'm gettin this error:

main.cpp.text+0xac2): undefined reference to `TheoraVideoClip::getNextFrame()'

Ubuntu 11.10

View 2 Replies View Related

C++ :: Calling Library From HTML Page

Jun 12, 2014

I would like to be able to call c++ library from HTML page. So on HTML page I have area for some possible input (url, name, email, etc) and that info is passed to c++ and calculated info and may email someone; or pull info from text file and display on html page. Realizing PHP or something similar would be easier, I really want to make these calls from HTML pages. ???

View 2 Replies View Related

C++ :: Export Classes In DLLs

Mar 6, 2015

Is there a way to export a c++ class for another language. I need to find an interpreted language that can use c++ classes (actually just one class) exported in DLLs. It wouldn't surprise me if you couldn't though because of how classes are handled in c++. Maybe python could do it because it's object oriented uses something very similar to the "this" pointer.

I have heard about something called COM.

View 7 Replies View Related

C/C++ :: How To Export Output To Excel

Dec 21, 2013

I've got a program in C that creates DATA. I need to export the DATA to excel, so I can re export to Access and use in the data base.

I also need to run the Builder in the C++ file every 5 minutes to generate the DATA based on time. How can I do that ?

View 2 Replies View Related

C++ :: How To Export Class With Template

Jun 3, 2014

I have the following class header in library, but when i initialize in main the class, i have an error unresolved external symbols. So the class is not exported as it should.

Code:

template <typename Key, typename Value>
class UTILITIES_EXPORT MyMap : public QMap<Key, Value>
{
public:
MyMap() : QMap<Key, Value>() { }

[Code]....

View 4 Replies View Related

C++ :: Output Of Dumpbin Export To See Functions Of A DLL

Apr 22, 2013

From the console of VCE I have run dumpbin export as

Code: dumpbin /export myDLL.dll

in order to see which functions is the dll providing. I got as an output:

Code: ordinal hint RVA name
1 0 00024B0 _Function1@4
2 1 00024E0 _Function2@0
.....
I think RVA means Relative Virtual Address, but what does the @4 or the @0 (or @16) means?

BTW the @# notation is a c-style function naming convention where the number is the size of the parameters accepted by the function. 4 might be an integer or a pointer on a 32-bit system.

If this is the case, I am guessing a @12 might mean three integers and @16 four integers?

View 1 Replies View Related

C# :: Take Data From GUI And Export Into Excel File

Jul 1, 2013

i'm kinda new to c#, i wanna create a program which will take few data from GUI and export it into an excel file. Another thing is how to modify the data displacement in that particular excel file?

View 6 Replies View Related

C# :: Export Windows Form To Excel?

May 3, 2015

I want to export the windows form in which text box,label and gridview ,gridview export to excel is working fine,but i need to export the whole form as such to excel.Is there any option to select Panel : This is my code:

private void btnExport_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Excel Documents (*.xls)|*.xls";

[Code].....

View 2 Replies View Related

C++ :: MinGW And Export Link Libs?

Jan 5, 2012

I'm building an app using VC++. The app links to a DLL built using TDM-GCC (which uses MinGW I think). Obviously, the DLL comes with a link lib.

If the lib is linked to another MinGW app, the DLL functions get found by name. So if the DLL builder updates his DLL, the MinGW app carries on working.

However, if the same lib is linked to a VC++ app, the functions get found by ordinal value. But MinGW doesn't seem to have any means of guaranteeing that a later build of the DLL will use the same numbering scheme. So his new DLL will break the pre-existing VC++ app that used it.

In VC++ this problem could be solved by using a DEF file but that doesn't seem to work in MinGW. So my question is:- can a DLL built with MinGW be somehow instructed to export its functions only by name - or at least to export them so that any other compiler will import them by name and not by ordinal numbers?

View 8 Replies View Related

C# :: Export Tabulated String To Excel File

Apr 9, 2014

I am able to export a tabulated string to an Excel file, when I open the file in Excel it looks fine (3 rows, 3 columns). However, the formatting seems a bit dodgy as I can't then read the same file back using C#. If I open it in Excel and do a save as, then I can read it from C#.

fileWriter = new System.IO.StreamWriter(@"C:Sheet1.xls"); //

This overwrites file each time by default.

fileWriter.Write("COL_A COL_B COL_C
1 2 3
10 20 30");
fileWriter.Close();

To read the Excel file back i'm using the following code:

OleDbConnection cnn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + (@"C:Sheet1.xls") + "; Extended Properties=Excel 12.0;");
OleDbCommand oconn = new OleDbCommand("select * from [Sheet1$]", cnn);
cnn.Open();
OleDbDataAdapter adp = new OleDbDataAdapter(oconn);
DataTable forceResultsTable = new DataTable();
adp.Fill(resultsDataTable);

The error I'm getting back is "OleDbException was unhandled" with "cnn.Open();" being highlighted in visual.

View 9 Replies View Related

C# :: CFD Program - How To Export Data Of Array Into XLS File In Different Sheets

Feb 11, 2014

I have written a CFD program that final results store at several 2D arrays. For instance, temperature of a square plate. For every point of plate i and j (i,j), I have a temperature amount. On the other hand, these temperatures change by time.

theSpace.TheCells[i, j,0].Temperature

I would like to save these data into an excel file and each sheet contains data for specific time (for example, an excel file with 50 sheets that cell number shows the coordinate of a point and the value in it is the temperature and next time step data's will be in the next sheet of current workbook )

I was thinking my code should be something like the following note, but it doesn't work:

// Implement time loop
int counter = 0;
for (int step= 1; step<= MaxSteps; step++) {
// call Excel output method
ExportData(ResultsArray,step,nx,ny);

[Code] ....

View 7 Replies View Related

C/C++ :: Loading TXT File To Convert Letters To Numbers And Export Again

Feb 5, 2015

I have been playing around with .txt and .dat files lately. I only manage to load the files, but I don't seem to be able to load files using a variable.

Also modifying the data after it is imported is also currently problematic. I know how to go about the process without the need to import anything, but whenever I import the data I am having trouble modifying/ editing the ".txt" or ".dat" data.

Below is my current code:

#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
ifstream file;
ofstream result;
char in_file_name[8], out_file_name[8];

[Code] ....

View 5 Replies View Related

C++ :: Shared Pointer Dropping?

Sep 19, 2014

Is their a way to completely drop a shared_ptr. Then it will delete the memory and NULL all pointers linking to it?

View 4 Replies View Related

C++ :: Shared Memory Between Processes

Apr 13, 2014

Say now I have a dll, loaded and run by a 32bit program. One of the things that I access from the program in the dll are several 1024x1024 int buffers. However I would like to put some data into those buffers from a external process. And I would like a separate thread in that external process for each buffer. Is there any way I can make that memory space accessible to the external process so I can use my own multi threaded memory transfers to pass that data over provided I ensure that the original process doesn't try to do anything with that data? And I would like to do this without resorting to the Read/WriteProcessMemory functions which are not threadsafe. In short, I want to set up direct memory access between the 2 programs without creating any intermediate shared memory buffers ie I want to set permissions for an existing memory space. Is this possible?

View 1 Replies View Related

C++ :: Multithreading - How To Modify Shared Object

Aug 24, 2014

class MyOwner {
...
int m_count;
bool b_locked;
};

[Code] ....

I am using an API where I create many MyObjects on the heap, and the API uses a separate thread to send messages to each object. Each MyObject contains a pointer to MyOwner.

Suppose I want to keep a count of all messages received in all MyObjects: How can I do this in a thread safe way?

I am assuming that the code I have written above will not be safe--at the very least it seems that it would potentially miss message counts when it was locked--not the worse case scenario for me. I am most concerned about not causing the application to crash.

View 5 Replies View Related

C++ :: Moving Objects To Shared Memory

Feb 9, 2013

I am not so experianced with c++ myself, but I need to evaluate if a certain idea might work.

I am working with a system for automation purposes that is running on a realtime OS in parallel to windows. Windows and the RTOS exchange data via shared memory. The application in the RTOS is compiled in C++. Now I would like to be able to influence the some data manipulation tasks in the RTOS application without changing the code of the RTOS application. So a concept like calling a dll.

My idea was to create a class with virtual methods in the RTOS application. The objects that are used should then be created on the Windows side with the same class prototype, but specific implementation of the virtual methods. The objects should then be moved to the shared memory, where they are used by the RTOS application.

Is something like this possible or am I completly on the wrong path?

View 4 Replies View Related

C++ :: Cannot Open Shared Object File

Nov 11, 2013

i'm writing a lexer, and i want to use boost::regex for it. im sure im using it right (just in case though)

while(!this->Source.empty())
{
if(regex_search(Start, End, Match, regex(""[^"]*""), Flags))

[code].....

someone told me to download the latest source and build that so i did, by unzipping it, cding to the source, running ./bootstrap.sh, ./b2, and finally ./b2 install. when i compile i get no errors but when i run it i get ./jade: error while loading shared libraries: libboost_regex.so.1.55.0: cannot open shared object file: No such file or directory

View 6 Replies View Related

C++ :: File Handling Vs Shared Memory?

May 27, 2014

In interprocess communication(IPC) when processe have to share data among each other,why cant they all connect to one single file and share data with basic file handling functions such as read and write?

Why do we need

shared memory(shmget shmat(),shmdt()..etc)
and
mapped memory(mmap(),munmap()..etc)

concepts?

View 3 Replies View Related

C :: How To Store Array Of Structure At Shared Memory

Jan 16, 2014

I have one requirement to store an array of structure at shared memory. Also the shared memory should have one counter to store number of elements in the array.

I tried to look at some placed but didn't find anything relevant.

So my first question, is it possible that we can store two things on same shared memory. And second if not then how to achieve the same?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved