Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7404767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:18:10+00:00 2026-05-29T05:18:10+00:00

Essentially what I have is this structure: PHP Application -> PHP Extension (in C++)

  • 0

Essentially what I have is this structure:

PHP Application -> PHP Extension (in C++) -> DLL Library (C++)

The DLL library calls functions inside itself, for example

int Library::FunctionA(){
       return Library::FunctionB + 4;
}

The problem is, when I try and call Library::Function A from my PHP extension, php crashes. I guess this is because php cannot call functions inside the DLL library (it cannot call Library::FunctionB from within the library) and therefore crashes?

The source code for the DLL Library is:

using namespace std;

namespace PMDInfo
{
class PMDParser
{
public:
    static __declspec(dllexport) string GetVariants(string FileName);
    static __declspec(dllexport) streamoff GetOffset(string FileName,streamoff offset);
};
}
 namespace PMDInfo {
       streamoff PMDParser::GetOffset(string FileName,streamoff offset){
            ifstream file2(FileName.c_str(), ios::binary);
            file2.seekg(offset);
         return (streamoff)file2.get();
   }

    string PMDParser::GetVariants(string FileName){
                    char *buffer1[40];
        ifstream ReadPMD(FileName.c_str(), ios::binary);
        streamoff begin = GetOffset(FileName,pmd_variant_name_table);       offsets
        streamoff end   = PMDInfo::PMDParser::GetOffset(FileName,pmd_group_table);
        return itoa(begin-end,buffer1,10);
    }
}

And the source code for the php extension:
using namespace std;

namespace PMDInfo
{
class PMDParser
{
public:
    static __declspec(dllimport) string GetVariants(string FileName);
    static __declspec(dllimport) streamoff GetOffset(string FileName,streamoff offset);
};
}

--- PHP EXTENSION initiation code in here, all works fine ---

ZEND_FUNCTION(GetVariants)
{   

int title_len;
char *title = "";

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &title, &title_len) == FAILURE) {
    RETURN_NULL();
}
RETURN_STRING(PMDInfo::PMDParser::GetVariants(title).c_str(),1);

}

The point at which the application crashes is in the dll library when calling GetOffset(FileName,pmd_variant_name_table);. Am I referencing the functions wrong or something, or is the DLL unable to call functions inside itself?

If this still isn’t very clear please say what isnt!
Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:18:11+00:00Added an answer on May 29, 2026 at 5:18 am

    Have you tried using Swig? It’s a preprocessor like tool to create everything you need to call C++ (or C) code from other languages, e.g. PHP, Perl, etc. You just have to provide a header with the symbols you’d like to make accessible and it will create the wrapper code to compile the library as well as code for the interfaces in your target language. More details and example code can be found here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a DOM document that looks essentially like this <categories> <category id=1/>
I essentially have the same goal as in this question: Calling a jQuery plugin
I'm wondering if anyone can do this. Say I have this folder structure: Folder
Preface: This is not much about how to structure code within files. I have
I have an application that is essentially working until I tried to implement an
I have situation where a publisher application essentially keeps a view model up to
If you have to use String.Replace() to replace test 50 times, you essentially have
Essentially I have a method of a class called killProgram, which is intended to
I have essentially a survey that is shown, and people answer questions a lot
I have essentially the same problem discussed here: http://khason.net/blog/dependency-property-getters-and-setters-in-multithreaded-environment/ public static readonly DependencyProperty MyPropertyProperty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.