473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

I can't seem to get Ctypes to find my c++ functions declared within a DLL file.

Jory R Ferrell
The following attachments may help better than my own description.

CTypes_1 is a picture of the python code calling the function from the DLL.

CTypes_2 is the code contained within the DLL. (Before compilation of course. The actual DLL looks nothing like this.)

CTypes_3 is the DLL located in the directory I am calling it from during import. It is clearly labeled as a DLL, so I didn't just try to use the wrong file type (would've thrown an error anyways).

CTypes_4 is the actual error output from python.

I have been using older tutorials I suppose, but I would assume that of the four or so ways I have seen people implement to load the files hasn't really changed all that much, so it must be something I am missing. Did I create the functions in the DLL incorrectly? Did I screw-up the import in the python code somehow? I am not seeing what the problem is. Thanks in advance.
Attached Images
File Type: jpg CTypes_1.jpg (17.9 KB, 414 views)
File Type: jpg CTypes_2.jpg (27.6 KB, 573 views)
File Type: jpg CTypes_3.jpg (13.5 KB, 295 views)
File Type: png CTypes_4.PNG (12.3 KB, 476 views)
Oct 28 '12 #1
2 3951
As for my choice of function names....mind your business. :P

(O_o)
Oct 28 '12 #2
Ok...ok...calm down everyone. I appreciate the OVERWHELMING amount of help I have received, but I found the answer on my own:
http://wolfprojects.altervista.org/dllforpyinc.php

Apparently you need to add a directive to the cpp code and then set-up the function for export as a dll asset. I JUST found this solution so I am not sure what makes it tick (I am not very familiar with c++), but I'll read up on it some and let you know what I find....if I even understand it... :P
I haven't seen any other examples that have to jump through this hoop when creating the dll (If they did, they left out some steps :/ ), but it's working now.
The following added to the c++ verision dll (diff for straight "C" code), gets the entire thing working:
Expand|Select|Wrap|Line Numbers
  1. // ConsApp.cpp : Defines the exported functions for the DLL application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #define DLLEXPORT extern "C" __declspec(dllexport)
  6.  
  7. DLLEXPORT int otters(int a, int b) {
  8.     return a + b;
  9. }
  10.  
  11. DLLEXPORT int ducks(int a, int b){
  12.     return(a-b);
  13. }
Oct 29 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Greg Baker | last post by:
I don't know what standard protocol is in this newsgroup. Am I allowed to post code and ask for help? I hope so.. :) Here's my problem: I am trying problem 127 of the valladolid online...
0
by: Scott Wilkins | last post by:
Hi! I'm an old VB ASP coder, and just started to get wet in ASP.NET this week. I've already run into one very simple problem I can't seem to figure out. In VB ASP code, I could write code,...
2
by: sbeerav | last post by:
Hi, I wanted to know if it is legal in XML to declare an element within itself. For example... <A> This is an element of type A. <A> This is another element of type A </A>
1
by: Webdiyer | last post by:
Hi,all,I want to call some API functions that inside a .lib file? DllImportAttribute can only load the dll files,are there any way that I could load a .lib file and call functions inside that file...
2
by: Rico | last post by:
Hello, I have an ASP web app with an SQL back end. I am currently migrating to a new Windows 2003 Server machine and SQL Server 2005 Express. When I import the old database, I'm trying to...
1
by: Kyote | last post by:
I'm using vs.net 2005 I've changed the setting on one of my previous projects. Changed the borderstyle to prevent resizing of my form. But I can't seem to find it in my current projections form....
1
by: bitong | last post by:
what's wrong with my work? Pls help #include <stdio.h> int subtractor (int x, int y); main() { int a=5; int d=93; int s; s=subtractor(a,d);
0
by: =?Utf-8?B?Sm9l?= | last post by:
This may seem a little silly but please bear with me... I have a page called Page1.aspx and a code behind Page1.aspx.cs. In the code behind I declare a class called OdsDataSource as a CHILD...
0
by: jimp | last post by:
Puzzled <scratching.head@example.comwrote: Look in the web server log file for errors. Does the web server have permission to that directory? -- Jim Pennino
3
by: smokymtnman | last post by:
I have a drop down menu that has grown so long that I am afraid it will be hidden at the bottom of the page. I am using a ssi file for navigation. I was wondering if I can use the same code but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.