Results 1 to 8 of 8

Thread: DLL function(s) problem

  1. #1
    Join Date
    Aug 2012
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Question DLL function(s) problem

    Simple question i have this code in an EXE:
    Qt Code:
    1. void foo(int var1);
    2. void foo(int var1,int var2);
    To copy to clipboard, switch view to plain text mode 
    so i can use both with the same name
    how can i use this in a DLL my Qt compiler says that the 2 function confilts

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL function(s) problem

    there are plenty of other resources on the net available for building (c++) dlls. This is nothing to do with Qt programming.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Aug 2012
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: DLL function(s) problem

    Qt is C++ , i didn't ask for trolling i asked for advice...
    Last edited by silur; 24th August 2012 at 17:51.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL function(s) problem

    Qt is not c++. Qt is a library built with c++.

    This is a Qt programming forum. You have not asked a Qt programming question.

    Maybe here http://www.qtcentre.org/forums/9-General-Programming is what you are looking for.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Aug 2012
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: DLL function(s) problem

    look go flame somewhere else i have a question i don't need a lecture what Qt u know I'M PROGRAMMING IN Qt do you think i don't know what it is?
    you are a programmer in Qt, so rather than trollin' answer or flame another post

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: DLL function(s) problem

    Well, you've posted in a wrong forum. That's it. If you're sure that's the correct place to ask then:
    Did you fill HEADERS & LIBS variables for your pro-file? What's the complete error message?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: DLL function(s) problem

    Quote Originally Posted by silur View Post
    look go flame somewhere else i have a question i don't need a lecture what Qt u know I'M PROGRAMMING IN Qt do you think i don't know what it is?
    you are a programmer in Qt, so rather than trollin' answer or flame another post
    Since you asked so nicely, and the fact that you seem unable to find your way into the correct forum, I will advise you to read my signature.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: DLL function(s) problem

    Quote Originally Posted by silur View Post
    Simple question i have this code in an EXE:
    Qt Code:
    1. void foo(int var1);
    2. void foo(int var1,int var2);
    To copy to clipboard, switch view to plain text mode 
    so i can use both with the same name
    how can i use this in a DLL my Qt compiler says that the 2 function confilts
    Firstly, there is no such beast as a Qt compiler. Your are using either a C++ or C compiler and this question has nothing to do with Qt.

    Now, to address the C++ question. By way of example, this code:
    Qt Code:
    1. #include <stdio.h>
    2.  
    3. void foo(int a) { printf("A = %d\n", a); }
    4.  
    5. void foo(int a, int b) { printf("A = %d B = %d\n", a, b); }
    6.  
    7. int main(int argc, char **argv) {
    8. foo(1);
    9. foo(2,3);
    10. return 0;
    11. }
    To copy to clipboard, switch view to plain text mode 

    Is perfectly valid C++, which allows overloaded functions, and compiles just fine with a C++ compiler. Despite deliberately using only C IO functions this code will not compile with a C compiler (GCC in my case), generating:
    Qt Code:
    1. gcc -o test main.c
    2. main.c:7:6: error: conflicting types for ‘foo’
    3. main.c:3:6: note: previous definition of ‘foo’ was here
    4. main.c: In function ‘main’:
    5. main.c:15:5: error: too few arguments to function ‘foo’
    6. main.c:7:6: note: declared here
    To copy to clipboard, switch view to plain text mode 
    You are most likely using C++ compiler, but this is still related.


    Even with a C++ compiler, if you have forward declarations in the include file for your library like this:
    Qt Code:
    1. #ifdef __cplusplus
    2. extern "C" {
    3. #endif
    4.  
    5. void foo(int var1);
    6. void foo(int var1,int var2);
    7.  
    8. #ifdef __cplusplus
    9. }
    10. #endif
    To copy to clipboard, switch view to plain text mode 
    then you are telling the C++ compiler these are C-style declarations and it will not allow the overloaded names (just like a C compiler):
    Qt Code:
    1. g++ -o test test.cpp main.cpp
    2. In file included from main.cpp:1:0:
    3. test.h:6:27: error: declaration of C function ‘void foo(int, int)’ conflicts with
    4. test.h:5:6: error: previous declaration ‘void foo(int)’ here
    5. main.cpp: In function ‘int main(int, char**)’:
    6. main.cpp:6:10: error: too few arguments to function ‘void foo(int, int)’
    7. test.h:6:6: note: declared here
    To copy to clipboard, switch view to plain text mode 

    Exactly what you are doing we cannot tell, but this information should give you a clue.
    Last edited by ChrisW67; 25th August 2012 at 08:06.

Similar Threads

  1. problem with winevent Function
    By Mohammad in forum Newbie
    Replies: 3
    Last Post: 13th November 2011, 00:21
  2. Big problem with QVector::apend() function
    By Zander87 in forum Qt Programming
    Replies: 2
    Last Post: 3rd April 2010, 21:23
  3. Is that any problem in my this function?
    By HelloDan in forum Qt Programming
    Replies: 21
    Last Post: 3rd April 2009, 17:31
  4. problem with virtual function in a .h
    By mickey in forum General Programming
    Replies: 5
    Last Post: 19th April 2008, 18:57
  5. Problem with swprintf function
    By moowy in forum General Programming
    Replies: 6
    Last Post: 8th May 2007, 20:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.