Hi I have been trying to get a proceedure for using sapi (text to speech) using dev c++. I can easily get it working on c# but then I'm limited by the Visual Studio licence agreements. I have managed to get something to compile, but it wont make an executable because it has linker errors. Heres the code:
include <cstdlib>
include <iostream>
include <windows.h>
//#include <stdafx.h>
include <Servprov.h>
include <sapi.h>
using namespace std;
ISpVoice* Voice = NULL; // The voice interface
int main ( int NumOfArguments, char** Argument )
{
// Initialize COM
CoInitialize ( NULL );
I have made a sapi.a file using impdef, but the routines I get out of the sapi.dll file don't fit the ones that the linker is saying it can't find.
Has anyone managed to get this working? and can they give me a copy of the code, or even the whole proceedure needed to undertake to get this working. I only want to use the text to speech. not the voice recognition.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My appologies again. I am by no means an expert in Dev c++ and Mingw, I just love using it. But thanks for the tips. Here's what I think you've been asking for:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\projects\Makefile.win"
Executing make clean
rm -f main.o Project1.exe
main.o(.text+0x132):main.cpp: undefined reference to CoInitialize@4'
main.o(.text+0x145):main.cpp: undefined reference toIID_ISpVoice'
main.o(.text+0x15c):main.cpp: undefined reference to CLSID_SpVoice'
main.o(.text+0x161):main.cpp: undefined reference toCoCreateInstance@20'
main.o(.text+0x1c6):main.cpp: undefined reference to `CoUninitialize@0'
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
Like I said, I'm no expert, but it seems to me like the processes it's looking for are not in the dll library I've linked, but perhaps in something else that it wants to link to or something like that. But my code is copied from somewhere (I can't even remember where) on the net, where someone else was asking for help, with no solution. Let me reiterate my first questions: Has anyone got sapi working in Devc++, and is there some code I could use? My code is probably flawed, but maybe someone out there can help me with code that's useable? But to everyone who has given me tips: Thanks for letting me know where the log is, I would not have known before.
Thanks,
Russell.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to follow those steps you mentioned
I have a question about using the reimp tool.
At the command line I type : reimp -s sapi.lib
and it creates a file sapilib.obj
Is that all i'm supposed to do ? Am I to manually rename that obj file libsapi.a
Or should I do another step like this to generate the libsapi.a file?
Woops - ignore those mysql references in the previous post.
I know nothing about how reimp works or what it does.
I am guessing the procedure I described to simply reimp sapi.lib and renaming the resulting sapilib.obj to libsapi.a is wrong because of my resulting compile error . Here's my compiler log.
(By the way I added libole32.lib already in DevCPP/lib and libsapi.a of my own devising to the linker)
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make clean
rm -f FirstMicrosoftSpeechEffort.o SpeechTest.exe
Please disregard those references to libmysql.lib.
I don't know what reimp is or it's real purpose.
But I'm guessing that simply renaming the resulting sapilib.obj file might be wrong. Because when i renamed it to libsapi.a and added it to linker, I got a compiler error
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make clean
rm -f FirstMicrosoftSpeechEffort.o SpeechTest.exe
Well, I can't blame Clifford for providing somewhat out of date information, but just the same, it is outdated. I just checked out the documentation for various bits. Some of the documentation is outdated and somewhat incorrect.
This nonsense, the "Reimp dance", may be needed depending on what versions of 'GCC', 'LD', and 'DLLTool' you have. That said, depending on what versions of 'REIMP', 'DLLTOOL', and 'LD' you have, it may never work.
My advice, update to the latest version of 'LD', part of BINUTILS, and 'GCC' you can get your hands on. With the latest versions you can simply link the Microsoft libraries, both '.LIB' and '.DLL', directly. Exactly what you should do depends on the situation, but in this case, simply linking the Microsoft library will work. If you want simplicity you can simply rename the '.LIB'. The point is, with the latest version this crap is not needed. The only caveat, GCC doesn't use Microsoft conventions regarding the C++ ABI; the library will either need to be COM, or similar, or strait C.
This is a linker warning and only a linker warning. Odds are that your application has built to completion and will run as correctly as you have programmed it to run. If the warning bugs you, you can open the '.LIB' or '.A.' in a HEXEditor and replace "/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib"" with zeros (everything inside the surrounding quotes). Or, if you are very lucky, you'll find the source for a tool I wrote still around on this forum to "erase" Microsoft specific directives like that.
Soma
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well I also have hinted a number of times that I used impdef to get the functions and create a def file, then I used dlltool to create the sapi.a file. My problem is that dev is telling me it wants functions that impdef says aren't in the dll. Now get off my case about it please. I am a hobbiest not a qualified programmer. I come wanting guidance for a process to take, not someone telling me I've done it all wrong. I know that. That's why it's not linking.
I am curious about the suggestion that the newest gcc can use Microsoft libraries. Do you think I should try installing it? Would this help? Once again (which i also have stated before too mate) has anyone got sapi to work in dev c++? Simple question, why all the dribble about how I suck?!
Thanks,
Russell
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hoooray!!! Done guys. I reinstalled Dev c++ to make sure I got the latest gcc and then linked the MS library in instead of trying to create one.
the code is as follows:
include <cstdlib>
include <iostream>
include <windows.h>
include <Servprov.h>
include <sapi.h>
using namespace std;
ISpVoice* Voice = NULL; // The voice interface
int main ( int NumOfArguments, char** Argument )
{
// Initialize COM
CoInitialize ( NULL );
// Create the voice interface object
CoCreateInstance ( CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void**)&Voice );
// Speak!
Voice -> Speak ( L"Who the man!!!", SPF_DEFAULT, NULL );
// Shutdown the voice
if ( Voice != NULL ) Voice -> Release (); Voice = NULL;
// Shutdown COM
CoUninitialize ();
return 0;
}
you will need to linksapi.lib and ole32.a
Thanks for all the tips, but just a note I found it more constructive to hear other people ideas then get my own mistakes pointed out over and over. I hope somehow this has helped you if speech will be handy for you too.
Thanks, and God bless,
Russell
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Well I also have [...] dribble about how I suck?!"
To be honest, I didn't read this thread with a critical eye, but those comments warranted a "full read". The "dribble" was mostly useful information. If you choose to ignore it, then you do suck.
After reading the thread, it is obvious that your problem is now solved precisely because Clifford and I didn't bother to actually answer your "simple question" but offer support in finding a plausible solution. However, I will answer you now: I have never used 'SAPI' at all.
Are you satisfied with that answer?
And, for your future information, or others, the "functions" that 'LD' was complaining about, the apparent root of your problem, are not functions. Those bits are data only. The failure in "exporting" data is a known compatibility "problem" which you could have discovered by reading this very forum or the MGW archives.
"To be honest... I have never used reimp! I usually just tell people that and they work it out for themselves!"
Which is why I attributed to the outdated, partial information to the documentation.
Soma
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-07-18
I stand corrected. Although this is the first instance I have heard of anyone linking teh MS library directly. Then again I guess teh ones doing it had no problem and so never asked teh question. I'll go back to my ARM code now then ;-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You didn't post your compile log, which would help us see what is linked and what it is complaining about. Please post your full "Basic 3" - they are covered in the thread titled "Please Read Before Posting a Question"
Thanks,
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-07-15
>> I'm limited by the Visual Studio licence agreements
Really!?, In what way? It seems unlikely somehow.
Since the code compiles but does not link, the code alone is not that useful, what are the error messages, what libraries did you link - all would be revealed simply by posting the log.
The likelihood is that you are trying to use a Microsoft export library or that you have not linked the export library at all. You will need a MinGW compatible export library (usually of the form libXXX.a rather than XXX.lib)
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My apologies for not including the right info to begin with. It was late at night, etc etc. But no excuse. Well here's the info I can give. I'm assuming that by compile log you mean the output notes at the bottom of the screen. I can't find a log file in my directory.
And yes, I can't find the licence agreement I clicked yes to but I remember that it said i couldn't give my code away, unlike the gnu licences, and I read somewhere that i need to include a splash screen and a few extras. All of which I can't do in c# yet.
Dev c++:
version 4.9.9.2
Output of my linker: [Linker error] undefined reference to CoInitialize@4'
[Linker error] undefined reference toIID_ISpVoice' [Linker error] undefined reference to CLSID_SpVoice'
[Linker error] undefined reference toCoCreateInstance@20' [Linker error] undefined reference to `CoUninitialize@0'
ld returned 1 exit status
C:\Dev-Cpp\projects\Makefile.win [Build Error][Project1.exe] Error 1
I'd fill in the details into the def file of the routines, but they arn't the same as the ones it's trying to link.
The only thing I've manually linked is the library i've created from the def file, ie libsapi.a.
Thanks,
Russell
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is no need to guess on what to post. The directions on how to post the "Basic 3"
tell you exactly what to get, and how to get it.
The compile log is on the tab labeled "Compile Log", NOT the tab labeled "Compiler",
and the right mouse button brings up the copy menu. NEVER excerpt the errors, post
the log from the start - we need to see how the compiler was invoked. If you have
a ton of errors, just post from the start of the log through the first 5 or so errors.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-07-15
>> I'm assuming that by compile log you mean the output notes at the bottom of the screen.
No it means the text content of the the tab labelled "Compile Log" at the bottom of the screen. CoInitialize, CoCreateInstance, and CoUninitialize requite libole32.a to be linked. In general where the Microsoft documentation ( http://msdn2.microsoft.com/en-us/library/ms678543.aspx ) says XXX.lib, you change this to XXX.a for MinGW.
main.o(.text+0x145):main.cpp: undefined reference to IID_ISpVoice'
main.o(.text+0x15c):main.cpp: undefined reference toCLSID_SpVoice'
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
I would have thought these would be dealt with inside the sapi.h file, or at least show up in the sapi.dll?
Russell.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-07-16
>>
>> but I still have problems with 2 functions
>>
Of course you do. I said you would.
>>
>>I would have thought these would be dealt with inside the sapi.h
>>
No! A header file simply declares the prototypes of functions in order to satisfy the compiler for individual compilation units. They remain in the compiled object code as "unresolved external references", the linker has to find these external references in order to resolve them and fully link the code to produce an executable.
>>
>> or at least show up in the sapi.dll
>>
They are in the DLL, but that is not what the linker looks at or needs, it requires an export library. This contains information about the DLL to allow the linker to resolve the external references with the "promise" that the DLL will be present at run-time.
As I said (twice now) you need to link the SAPI export library. And as I pointed out also twice, you may not have a MinGW SAPI export library. So as I also said earlier you take SAPI.lib and use the reimp.exe tool to created libSAPI.a, then link that (-lsapi).
If you don't have a suitable export library, then you can load the library at run-time using LoadLibrary() and GetProcAddress().
I note that you have tried to link a ../lib/libsapi.a file, so either it does not exist at that path or it does not contain the missing functions. It may even not be of the correct format - where did you get it from, or how did you create it?
Note you have added ../lib/libsapi.a ../lib/libole32.a, but you can use the short-hand: -lsapi -lole32, if these libraries are in the default library path. The linker assumes "lib" and ".a". Incidentally your default library path (-L"lib"), has been changed from the default C:\Dev-Cpp\Lib; you should not do that, you can add additional paths if you wish, but don't screw with the standard one!
You should avoid creating projects in sub-folders of C:\Dev-Cpp, apart from potentially messing up your installation, and making re-installations more difficult (and you may even loose your work), and otherwise being a "thoroughly bad idea(tm)", there is a known bug in Dev-C++ that sometimes causes such projects to fail to build.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-07-18
To be honest... I have never used reimp! I usually just tell people that and they work it out for themselves! ;-)
Hi I have been trying to get a proceedure for using sapi (text to speech) using dev c++. I can easily get it working on c# but then I'm limited by the Visual Studio licence agreements. I have managed to get something to compile, but it wont make an executable because it has linker errors. Heres the code:
include <cstdlib>
include <iostream>
include <windows.h>
//#include <stdafx.h>
include <Servprov.h>
include <sapi.h>
using namespace std;
ISpVoice* Voice = NULL; // The voice interface
int main ( int NumOfArguments, char** Argument )
{
// Initialize COM
CoInitialize ( NULL );
}
I have made a sapi.a file using impdef, but the routines I get out of the sapi.dll file don't fit the ones that the linker is saying it can't find.
Has anyone managed to get this working? and can they give me a copy of the code, or even the whole proceedure needed to undertake to get this working. I only want to use the text to speech. not the voice recognition.
Thanks.
My appologies again. I am by no means an expert in Dev c++ and Mingw, I just love using it. But thanks for the tips. Here's what I think you've been asking for:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\projects\Makefile.win"
Executing make clean
rm -f main.o Project1.exe
g++.exe -c main.cpp -o main.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
g++.exe main.o -o "Project1.exe" -L"lib" ../lib/libsapi.a
main.o(.text+0x132):main.cpp: undefined reference to
CoInitialize@4' main.o(.text+0x145):main.cpp: undefined reference to
IID_ISpVoice'main.o(.text+0x15c):main.cpp: undefined reference to
CLSID_SpVoice' main.o(.text+0x161):main.cpp: undefined reference to
CoCreateInstance@20'main.o(.text+0x1c6):main.cpp: undefined reference to `CoUninitialize@0'
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
Like I said, I'm no expert, but it seems to me like the processes it's looking for are not in the dll library I've linked, but perhaps in something else that it wants to link to or something like that. But my code is copied from somewhere (I can't even remember where) on the net, where someone else was asking for help, with no solution. Let me reiterate my first questions: Has anyone got sapi working in Devc++, and is there some code I could use? My code is probably flawed, but maybe someone out there can help me with code that's useable? But to everyone who has given me tips: Thanks for letting me know where the log is, I would not have known before.
Thanks,
Russell.
Hi Russel
You said
"But my code is copied from somewhere (I can't even remember where) on the net, where someone else was asking for help, with no solution. "
Guess what it was me who posted that code - i recognize my includes.
Looks like we figured it out at the same time.
Good luck with it.
Stephen
Hi Clifford
I have the identical issue.
I am trying to follow those steps you mentioned
I have a question about using the reimp tool.
At the command line I type : reimp -s sapi.lib
and it creates a file sapilib.obj
Is that all i'm supposed to do ? Am I to manually rename that obj file libsapi.a
Or should I do another step like this to generate the libsapi.a file?
C:> reimp -d libmysql.lib
C:> dlltool -d LIBMYSQL.def -D libmysql.dll -k -l libmysql.a
Thanks
Stephen
Hi I'm stephen again.
Woops - ignore those mysql references in the previous post.
I know nothing about how reimp works or what it does.
I am guessing the procedure I described to simply reimp sapi.lib and renaming the resulting sapilib.obj to libsapi.a is wrong because of my resulting compile error . Here's my compiler log.
(By the way I added libole32.lib already in DevCPP/lib and libsapi.a of my own devising to the linker)
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make clean
rm -f FirstMicrosoftSpeechEffort.o SpeechTest.exe
g++.exe -DDEBUG -c FirstMicrosoftSpeechEffort.cpp -o FirstMicrosoftSpeechEffort.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"D:/Program Files/Microsoft Speech SDK 5.1/Include" -g3
g++.exe -DDEBUG FirstMicrosoftSpeechEffort.o -o "SpeechTest.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" -L"D:/Program Files/Microsoft Speech SDK 5.1/Lib/i386" -L"D:/Program Files/Microsoft Speech SDK 5.1/IDL" -L"D:/Program Files/Microsoft Speech SDK 5.1/Lib" -L"D:/Program Files/Microsoft Speech SDK 5.1/Bin" lib/libole32.a lib/libsapi.a -g3
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Execution terminated
hoping for some clarification.
Thanks
Stephen
hi I'm Stephen - who made the last post.
Please disregard those references to libmysql.lib.
I don't know what reimp is or it's real purpose.
But I'm guessing that simply renaming the resulting sapilib.obj file might be wrong. Because when i renamed it to libsapi.a and added it to linker, I got a compiler error
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make clean
rm -f FirstMicrosoftSpeechEffort.o SpeechTest.exe
g++.exe -DDEBUG -c FirstMicrosoftSpeechEffort.cpp -o FirstMicrosoftSpeechEffort.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"D:/Program Files/Microsoft Speech SDK 5.1/Include" -g3
g++.exe -DDEBUG FirstMicrosoftSpeechEffort.o -o "SpeechTest.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" -L"D:/Program Files/Microsoft Speech SDK 5.1/Lib/i386" -L"D:/Program Files/Microsoft Speech SDK 5.1/IDL" -L"D:/Program Files/Microsoft Speech SDK 5.1/Lib" -L"D:/Program Files/Microsoft Speech SDK 5.1/Bin" lib/libole32.a lib/libsapi.a -g3
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Execution terminated
By the way I found reimp.exe on my pc under CodeBlocks/bin. Hoping that's a satisfactory imp.
And the libole32.a which I linked was already in Dev-CPP lib
Hoping for clarifcation on this .
Stephen
Well, I can't blame Clifford for providing somewhat out of date information, but just the same, it is outdated. I just checked out the documentation for various bits. Some of the documentation is outdated and somewhat incorrect.
This nonsense, the "Reimp dance", may be needed depending on what versions of 'GCC', 'LD', and 'DLLTool' you have. That said, depending on what versions of 'REIMP', 'DLLTOOL', and 'LD' you have, it may never work.
My advice, update to the latest version of 'LD', part of BINUTILS, and 'GCC' you can get your hands on. With the latest versions you can simply link the Microsoft libraries, both '.LIB' and '.DLL', directly. Exactly what you should do depends on the situation, but in this case, simply linking the Microsoft library will work. If you want simplicity you can simply rename the '.LIB'. The point is, with the latest version this crap is not needed. The only caveat, GCC doesn't use Microsoft conventions regarding the C++ ABI; the library will either need to be COM, or similar, or strait C.
"'Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized'"
This is a linker warning and only a linker warning. Odds are that your application has built to completion and will run as correctly as you have programmed it to run. If the warning bugs you, you can open the '.LIB' or '.A.' in a HEXEditor and replace "/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib"" with zeros (everything inside the surrounding quotes). Or, if you are very lucky, you'll find the source for a tool I wrote still around on this forum to "erase" Microsoft specific directives like that.
Soma
Well I also have hinted a number of times that I used impdef to get the functions and create a def file, then I used dlltool to create the sapi.a file. My problem is that dev is telling me it wants functions that impdef says aren't in the dll. Now get off my case about it please. I am a hobbiest not a qualified programmer. I come wanting guidance for a process to take, not someone telling me I've done it all wrong. I know that. That's why it's not linking.
I am curious about the suggestion that the newest gcc can use Microsoft libraries. Do you think I should try installing it? Would this help? Once again (which i also have stated before too mate) has anyone got sapi to work in dev c++? Simple question, why all the dribble about how I suck?!
Thanks,
Russell
Hoooray!!! Done guys. I reinstalled Dev c++ to make sure I got the latest gcc and then linked the MS library in instead of trying to create one.
the code is as follows:
include <cstdlib>
include <iostream>
include <windows.h>
include <Servprov.h>
include <sapi.h>
using namespace std;
ISpVoice* Voice = NULL; // The voice interface
int main ( int NumOfArguments, char** Argument )
{
// Initialize COM
CoInitialize ( NULL );
}
you will need to linksapi.lib and ole32.a
Thanks for all the tips, but just a note I found it more constructive to hear other people ideas then get my own mistakes pointed out over and over. I hope somehow this has helped you if speech will be handy for you too.
Thanks, and God bless,
Russell
I also have it working as well.
Initially I used " reimp sapi.lib " to create sapilib.obj - which I renamed to libsapi.a and linked it , that compiled with the error
Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" ' unrecognized
Execution terminated
But when I run it - it works.
Also I read the other post and decided simply link the original sapi.lib - rather than libsapi a , I get the same warning but it also works .
I was just hoping to see "compilation successful at the end"
Stephen
"Well I also have [...] dribble about how I suck?!"
To be honest, I didn't read this thread with a critical eye, but those comments warranted a "full read". The "dribble" was mostly useful information. If you choose to ignore it, then you do suck.
After reading the thread, it is obvious that your problem is now solved precisely because Clifford and I didn't bother to actually answer your "simple question" but offer support in finding a plausible solution. However, I will answer you now: I have never used 'SAPI' at all.
Are you satisfied with that answer?
And, for your future information, or others, the "functions" that 'LD' was complaining about, the apparent root of your problem, are not functions. Those bits are data only. The failure in "exporting" data is a known compatibility "problem" which you could have discovered by reading this very forum or the MGW archives.
"To be honest... I have never used reimp! I usually just tell people that and they work it out for themselves!"
Which is why I attributed to the outdated, partial information to the documentation.
Soma
I stand corrected. Although this is the first instance I have heard of anyone linking teh MS library directly. Then again I guess teh ones doing it had no problem and so never asked teh question. I'll go back to my ARM code now then ;-)
Thanks for the help Stephen, your initial code was a lifeline.
You didn't post your compile log, which would help us see what is linked and what it is complaining about. Please post your full "Basic 3" - they are covered in the thread titled "Please Read Before Posting a Question"
Thanks,
Wayne
>> I'm limited by the Visual Studio licence agreements
Really!?, In what way? It seems unlikely somehow.
Since the code compiles but does not link, the code alone is not that useful, what are the error messages, what libraries did you link - all would be revealed simply by posting the log.
The likelihood is that you are trying to use a Microsoft export library or that you have not linked the export library at all. You will need a MinGW compatible export library (usually of the form libXXX.a rather than XXX.lib)
Clifford
My apologies for not including the right info to begin with. It was late at night, etc etc. But no excuse. Well here's the info I can give. I'm assuming that by compile log you mean the output notes at the bottom of the screen. I can't find a log file in my directory.
And yes, I can't find the licence agreement I clicked yes to but I remember that it said i couldn't give my code away, unlike the gnu licences, and I read somewhere that i need to include a splash screen and a few extras. All of which I can't do in c# yet.
Dev c++:
version 4.9.9.2
Output of my linker:
[Linker error] undefined reference to
CoInitialize@4' [Linker error] undefined reference to
IID_ISpVoice'[Linker error] undefined reference to
CLSID_SpVoice' [Linker error] undefined reference to
CoCreateInstance@20'[Linker error] undefined reference to `CoUninitialize@0'
ld returned 1 exit status
C:\Dev-Cpp\projects\Makefile.win [Build Error] [Project1.exe] Error 1
My def file from the sapi.dll:
LIBRARY SAPI.DLL
EXPORTS
_DllCanUnloadNow = DllCanUnloadNow ; DllCanUnloadNow
_DllGetClassObject = DllGetClassObject ; DllGetClassObject
_DllRegisterServer = DllRegisterServer ; DllRegisterServer
_DllUnregisterServer = DllUnregisterServer ; lUnregisterServer
_RunSapiServer = RunSapiServer ; RunSapiServer
I'd fill in the details into the def file of the routines, but they arn't the same as the ones it's trying to link.
The only thing I've manually linked is the library i've created from the def file, ie libsapi.a.
Thanks,
Russell
There is no need to guess on what to post. The directions on how to post the "Basic 3"
tell you exactly what to get, and how to get it.
The compile log is on the tab labeled "Compile Log", NOT the tab labeled "Compiler",
and the right mouse button brings up the copy menu. NEVER excerpt the errors, post
the log from the start - we need to see how the compiler was invoked. If you have
a ton of errors, just post from the start of the log through the first 5 or so errors.
Wayne
>> I'm assuming that by compile log you mean the output notes at the bottom of the screen.
No it means the text content of the the tab labelled "Compile Log" at the bottom of the screen. CoInitialize, CoCreateInstance, and CoUninitialize requite libole32.a to be linked. In general where the Microsoft documentation ( http://msdn2.microsoft.com/en-us/library/ms678543.aspx ) says XXX.lib, you change this to XXX.a for MinGW.
According to http://msdn2.microsoft.com/en-us/library/ms720163.aspx#SettingUpTheProject ypu need SAPI.lib, but this is a Microsoft library and will not work, and there is no MinGW version supplied with the MinGW distribution. You may be able to convert it with the reimp.exe tool.
It would be easier to simply use the Microsoft tools. You never expanded on the license issues.
Clifford
Updated compile log. I linked the libole32.a in with it, but I still have problems with 2 functions:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\projects\Makefile.win"
Executing make clean
rm -f main.o Project1.exe
g++.exe -c main.cpp -o main.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
g++.exe main.o -o "Project1.exe" -L"lib" ../lib/libsapi.a ../lib/libole32.a
main.o(.text+0x145):main.cpp: undefined reference to
IID_ISpVoice' main.o(.text+0x15c):main.cpp: undefined reference to
CLSID_SpVoice'collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
I would have thought these would be dealt with inside the sapi.h file, or at least show up in the sapi.dll?
Russell.
>>
>> but I still have problems with 2 functions
>>
Of course you do. I said you would.
>>
>>I would have thought these would be dealt with inside the sapi.h
>>
No! A header file simply declares the prototypes of functions in order to satisfy the compiler for individual compilation units. They remain in the compiled object code as "unresolved external references", the linker has to find these external references in order to resolve them and fully link the code to produce an executable.
>>
>> or at least show up in the sapi.dll
>>
They are in the DLL, but that is not what the linker looks at or needs, it requires an export library. This contains information about the DLL to allow the linker to resolve the external references with the "promise" that the DLL will be present at run-time.
As I said (twice now) you need to link the SAPI export library. And as I pointed out also twice, you may not have a MinGW SAPI export library. So as I also said earlier you take SAPI.lib and use the reimp.exe tool to created libSAPI.a, then link that (-lsapi).
If you don't have a suitable export library, then you can load the library at run-time using LoadLibrary() and GetProcAddress().
I note that you have tried to link a ../lib/libsapi.a file, so either it does not exist at that path or it does not contain the missing functions. It may even not be of the correct format - where did you get it from, or how did you create it?
Note you have added ../lib/libsapi.a ../lib/libole32.a, but you can use the short-hand: -lsapi -lole32, if these libraries are in the default library path. The linker assumes "lib" and ".a". Incidentally your default library path (-L"lib"), has been changed from the default C:\Dev-Cpp\Lib; you should not do that, you can add additional paths if you wish, but don't screw with the standard one!
You should avoid creating projects in sub-folders of C:\Dev-Cpp, apart from potentially messing up your installation, and making re-installations more difficult (and you may even loose your work), and otherwise being a "thoroughly bad idea(tm)", there is a known bug in Dev-C++ that sometimes causes such projects to fail to build.
Clifford
To be honest... I have never used reimp! I usually just tell people that and they work it out for themselves! ;-)
As I understand it you use the .def output of reimp and feed that to dlltool: http://jrfonseca.dyndns.org/projects/gnu-win32/software/reimp/index.html
Check out the reimp ReadMe file for full details, there are a few gotchas. It is apparently at http://cvs.sourceforge.net/viewcvs.py/mingw/utils/reimp/README?rev=1.2 but I had more luck getting it from Google cache: http://66.102.9.104/search?q=cache:0NSZp_Z0pc8J:cvs.sourceforge.net/viewcvs.py/mingw/utils/reimp/README%3Frev%3D1.2+reimp+readme&hl=en&ct=clnk&cd=3&gl=uk
Clifford