Author Topic: Transfering project from VS to CodeBlocks  (Read 24890 times)

Offline user321

  • Single posting newcomer
  • *
  • Posts: 9
Transfering project from VS to CodeBlocks
« on: June 02, 2013, 10:35:15 pm »
I'm trying to compile some code from this website http://headsoft.com.au/index.php?category=vjoy  (SDK C++) in CodeBlocks.

Its working in VS (there is .dsp file), but I don't really like it. So I created new project in CodeBlocks included all files, linked library (I think I dd it good), but I just can't get it to compile :S

If I press "Keep this relative path"> Yes while adding library, then I get error ld.exe||cannot find -lVJoy.lib

If I press "Keep this relative path"> No while adding library, then I get following error :

obj\Debug\x\main.o||In function `main':|
\main.cpp|12|undefined reference to `_imp___Z15VJoy_InitializePcS_@8'|
\main.cpp|20|undefined reference to `_imp___Z19VJoy_UpdateJoyStateiP15_JOYSTICK_STATE@8'|
\main.cpp|22|undefined reference to `_imp___Z13VJoy_Shutdownv@0'|
||=== Build finished: 3 errors, 0 warnings (0 minutes, 0 seconds) ===|


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline user321

  • Single posting newcomer
  • *
  • Posts: 9
Re: Transfering project from VS to CodeBlocks
« Reply #2 on: June 03, 2013, 01:01:14 am »
Thanks for the link, I didn't know its possible to import VC++ project, but even when I import this project which is working flawlessly on VC, its getting me same errors as before. I know that errors are about linking library, but why are they happening :S

BTW
I encountered CodeBlocks crash.
First I clicked on import Visual C++, then import Visual Studio project while project was opened, select compiler... and crash each time. would be nice to fix this.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Transfering project from VS to CodeBlocks
« Reply #3 on: June 03, 2013, 01:03:27 am »
about the crash: Start with your OS/C::B/compiler versions. Guessing them would be impossible, because my magic ball is out of mana!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline user321

  • Single posting newcomer
  • *
  • Posts: 9
Re: Transfering project from VS to CodeBlocks
« Reply #4 on: June 03, 2013, 01:25:31 am »
oh sorry, I forgot to mention  ???

I am using Windows 7 x64
Codeblocks 12.11
and compiler is the standard one which comes with 12.11 (GNU)

Maybe someone else could also try to import that project and maybe confirm crash?
 once I import .dsp file, guess it somehow locks .vcproj (overwrites?) , and when it tries to open it ... crashes?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Transfering project from VS to CodeBlocks
« Reply #5 on: June 03, 2013, 06:12:58 pm »
FYI: Code::Blocks is a C++ IDE!!
It is NOT a VB or C# IDE.

Importing VB or C# projects was never supported!!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline user321

  • Single posting newcomer
  • *
  • Posts: 9
Re: Transfering project from VS to CodeBlocks
« Reply #6 on: June 03, 2013, 06:41:25 pm »
FYI: Code::Blocks is a C++ IDE!!
It is NOT a VB or C# IDE.

Importing VB or C# projects was never supported!!

Tim S.
where did I mention C# or basic?  ???
I know its C++ IDE, and I'm trying to import C++ project ...

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Transfering project from VS to CodeBlocks
« Reply #7 on: June 03, 2013, 08:16:33 pm »
Apologies,  I thought dsp was in C# or VB folder.

I imported the dsp project and it gave errors/warning during importing; but, I saw no crash of CB.

I used Windows 7 32 bit and Code::Blocks 12.11

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline user321

  • Single posting newcomer
  • *
  • Posts: 9
Re: Transfering project from VS to CodeBlocks
« Reply #8 on: June 03, 2013, 08:39:03 pm »
Apologies,  I thought dsp was in C# or VB folder.

I imported the dsp project and it gave errors/warning during importing; but, I saw no crash of CB.

I used Windows 7 32 bit and Code::Blocks 12.11

Tim S.
Did you tried to import MS Visual Studio Project after you already imported and have opened Visual C++ project (.dsp).

For me crash happens like that.

Anyway, did you successed to build it ?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Transfering project from VS to CodeBlocks
« Reply #9 on: June 03, 2013, 10:32:32 pm »
For me crash happens like that.
Samples and steps to reproduce please, otherwise you producing forum noise and we cant help.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Transfering project from VS to CodeBlocks
« Reply #10 on: June 03, 2013, 11:08:44 pm »
If I press "Keep this relative path"> Yes while adding library, then I get error ld.exe||cannot find -lVJoy.lib

If I press "Keep this relative path"> No while adding library, then I get following error :

obj\Debug\x\main.o||In function `main':|
\main.cpp|12|undefined reference to `_imp___Z15VJoy_InitializePcS_@8'|
\main.cpp|20|undefined reference to `_imp___Z19VJoy_UpdateJoyStateiP15_JOYSTICK_STATE@8'|
\main.cpp|22|undefined reference to `_imp___Z13VJoy_Shutdownv@0'|
||=== Build finished: 3 errors, 0 warnings (0 minutes, 0 seconds) ===|

Can you post the build log? Not the build Messages but the build log!

Offline user321

  • Single posting newcomer
  • *
  • Posts: 9
Re: Transfering project from VS to CodeBlocks
« Reply #11 on: June 03, 2013, 11:25:29 pm »
For me crash happens like that.
Samples and steps to reproduce please, otherwise you producing forum noise and we cant help.
Here is short video of how it happens : http://www.mediafire.com/download/q9ku3l755ynlwu5/crash2.7z


If I press "Keep this relative path"> Yes while adding library, then I get error ld.exe||cannot find -lVJoy.lib

If I press "Keep this relative path"> No while adding library, then I get following error :

obj\Debug\x\main.o||In function `main':|
\main.cpp|12|undefined reference to `_imp___Z15VJoy_InitializePcS_@8'|
\main.cpp|20|undefined reference to `_imp___Z19VJoy_UpdateJoyStateiP15_JOYSTICK_STATE@8'|
\main.cpp|22|undefined reference to `_imp___Z13VJoy_Shutdownv@0'|
||=== Build finished: 3 errors, 0 warnings (0 minutes, 0 seconds) ===|

Can you post the build log? Not the build Messages but the build log!


-------------- Build: Win32 Release in VJoy (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe  -o "...\VJoySDK\VJoy SDK\C++\Release\VJoy.exe" Release\StdAfx.o Release\VJoy.o    -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lcomctl32
Release\VJoy.o:VJoy.cpp:(.text.startup+0x1d): undefined reference to `_imp___Z15VJoy_InitializePcS_@8'
Release\VJoy.o:VJoy.cpp:(.text.startup+0x23): undefined reference to `_imp___Z13VJoy_Shutdownv@0'
Release\VJoy.o:VJoy.cpp:(.text.startup+0x79): undefined reference to `_imp___Z19VJoy_UpdateJoyStateiP15_JOYSTICK_STATE@8'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings (0 minutes, 0 seconds)
 

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Transfering project from VS to CodeBlocks
« Reply #12 on: June 03, 2013, 11:39:05 pm »
-------------- Build: Win32 Release in VJoy (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe  -o "...\VJoySDK\VJoy SDK\C++\Release\VJoy.exe" Release\StdAfx.o Release\VJoy.o    -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lcomctl32
Release\VJoy.o:VJoy.cpp:(.text.startup+0x1d): undefined reference to `_imp___Z15VJoy_InitializePcS_@8'
Release\VJoy.o:VJoy.cpp:(.text.startup+0x23): undefined reference to `_imp___Z13VJoy_Shutdownv@0'
Release\VJoy.o:VJoy.cpp:(.text.startup+0x79): undefined reference to `_imp___Z19VJoy_UpdateJoyStateiP15_JOYSTICK_STATE@8'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings (0 minutes, 0 seconds)
 

i think you miss VJoy.lib so, add it under Project->Build Options->Linker Settings
Add in Project->Build Options->Search Directories->Linker the path to  the lib, and if it fails again post again the build log
thx

Offline user321

  • Single posting newcomer
  • *
  • Posts: 9
Re: Transfering project from VS to CodeBlocks
« Reply #13 on: June 03, 2013, 11:45:09 pm »


i think you miss VJoy.lib so, add it under Project->Build Options->Linker Settings
Add in Project->Build Options->Search Directories->Linker the path to  the lib, and if it fails again post again the build log
thx
check first post:
If I press "Keep this relative path"> Yes while adding library, then I get error ld.exe||cannot find -lVJoy.lib

If I press "Keep this relative path"> No while adding library, then I get following error :

obj\Debug\x\main.o||In function `main':|
\main.cpp|12|undefined reference to `_imp___Z15VJoy_InitializePcS_@8'|
\main.cpp|20|undefined reference to `_imp___Z19VJoy_UpdateJoyStateiP15_JOYSTICK_STATE@8'|
\main.cpp|22|undefined reference to `_imp___Z13VJoy_Shutdownv@0'|
||=== Build finished: 3 errors, 0 warnings (0 minutes, 0 seconds) ===|

I already linked it, but for some reason it asks me do I want to keep this relative path to linker... dunno what that means :S I tried both options, but noone of them work ???

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Transfering project from VS to CodeBlocks
« Reply #14 on: June 03, 2013, 11:48:50 pm »

Keep this relative path> No

Keep relative path means, it saves the path relative to your project folder
No means it uses an absolute path.
For me adding only the library without path, and then adding the path in the Search path from the linker worked always.

Add in Project->Build Options->Search Directories->Linker the path
Can you post the build log? Not the build Messages but the build log!

Don't forget FULL BUILD LOG FROM BUILD MESSAGES

Offline user321

  • Single posting newcomer
  • *
  • Posts: 9
Re: Transfering project from VS to CodeBlocks
« Reply #15 on: June 04, 2013, 12:04:11 am »
If you succeded to build it, could you please upload zip of your project? also which compiler are you using?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Transfering project from VS to CodeBlocks
« Reply #16 on: June 04, 2013, 12:56:33 am »
If you succeded to build it, could you please upload zip of your project? also which compiler are you using?
This was a general help, not specific to your problem...
I don't know what you are trying to build. (And i don't have the time to make it for you, this is a good exercise to learn how compiler, linker and IDE work together)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Transfering project from VS to CodeBlocks
« Reply #17 on: June 04, 2013, 03:39:28 am »
FYI:

To convert a project from Compiler A to Compiler B.

You must know Compiler B very well. And, you should know a little about Compiler A.

Next, you need to know the basics of Compilers in General.

And, this project was written to only use C++ Visual Studio for Newbies.

I got it to link by doing three additional things past the Usual.

Note: I have no idea if it will Run or is Safe to run.

1. I defined "VJOY_EXPORTS"

2. I linked directly to the VJoy.dll using absolute path.
This is NOT a good thing to do; but, when you link to a Library you do NOT have the source code for you sometimes need to do it.

If the DLL has C linkage it should be safe.
No Idea what Linkage the DLL has it could be C++.

The third item is NOT one I would expect a Newbie to figure out. I modified the code.
The example should have been written in C if the DLL is really a C DLL; but, it is written in C++.
Either the person writing the sample code did NOT know very much or it is a C++ DLL.
Edit: Saving/Renaming the cpp file as a c files fixes the third problem without needing to edit the file.
Edit4: I am guessing the person who wrote the C++ file did not know very much about C++/C portability.

Original Code
Code
#include "VJoy.h"

Modified Code
Code
extern "C" {
#include "VJoy.h"
}

Note: None of my Answers are for questions allowed on this site; this thread is likely to be deleted or locked.

Edit2: These are answers appropriate to be asked and answered on a programming site like here http://cboard.cprogramming.com/forum.php

Edit2b: But, if you need help doing the three things I did to get the project to compile and link it would be OK to ask how to do it.
Edit3: But, please read the FAQ and the User Manual for items 1; I do NOT know of any FAQ to help with Items 2 and 3.


Tim S.
« Last Edit: June 04, 2013, 03:58:48 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org