adding library to linker

Monkey Targets Forums/Desktop/adding library to linker

Emil_halim(Posted 2014) [#1]
Hi all

is there a way to add library to linker ?


AdamRedwoods(Posted 2014) [#2]
only with the c++ target
#CC_OPTS = "-lname"
#CC_LIBS = "-ldllname"


dawlane(Posted 2014) [#3]
Not directly through Monkey. You would have to edit either a makefile or the Visual Studio solution to do it. I think Adam Redwoods mentioned something in one of the post a few months back about a push to git for a directive to add libraries to the build process for c++ tools target.

Edit: Adam must have posted just before me.


Emil_halim(Posted 2014) [#4]
thanks you AdamRedwoods , dawlane
so what about DeskTop?

Edited :
no problem i will extend DeskTop to accept library to link with.

thanks.


Emil_halim(Posted 2014) [#5]
Hi all

I have implemented it for desktop with gcc. works like Blitzmax

example
Import -lcomdlg32



here is the changes
==============
with gcc makefile
change this 
 LDLIBS= -lopengl32 -lOpenAL32 -lws2_32
to that
 LDLIBS=$(CCLIBS) -lopengl32 -lOpenAL32 -lws2_32


with parseMain function
Import will be like that

Case "import"
 	 NextToke
	If _toke = "-" 
	      Local line := _toke
	      NextToke
	      While _toke <> "~n"
		        line += _toke 
		        NextToke
	      Wend 
	      CC_Libs = line 
	Else If _tokeType=TOKE_STRINGLIT
		ImportFile EvalConfigTags( ParseStringLit() )
	Else
		ImportModule ParseModPath(),attrs
	Endif


in file translator.monkey put this line
Global CC_Libs$ 



AdamRedwoods(Posted 2014) [#6]
so what about DeskTop?

i don't know why #CC_OPTS is not in desktop. my guess is that it isn't so easy to pass flags to VS C++/C#.
you can pass CCFLAGS to Xcodebuild on OSX.


dawlane(Posted 2014) [#7]
As MSBuild is used to create desktop and xna applications. The Monkey compiler (trans) would need to edit the project properties (using /p: ) via the command line or construct a xml include file on the fly to be added as a parameter in the command line.
Like wise, using the gnu tool chain there is nothing to stop additional compiler options being passed as a variable to the makefile as long as the makefile is written in such away to allow for it.


Emil_halim(Posted 2014) [#8]
actually adding library to be included when linking stage with MSVC is very easy.

just emit the following line in c++ source code to include library
      #pragma comment(lib, "MyLibName.lib" )


any way i will remake import keyword to allow that for MSVC.


Danilo(Posted 2014) [#9]
Import -lcomdlg32


Did you try the following on Windows?
#LIBS+="Kernel32.lib"
#LIBS+="User32.lib"
#LIBS+="comdlg32.lib"

Extern
  Function Beep(dwFreq:Int, dwDuration:Int)
  Function MessageBeep(uType:Int)
Public

Function Main:Int()
  Beep(800,300)
  MessageBeep(-1)
  Return 0
End



Emil_halim(Posted 2014) [#10]
thanks Danilo for that.
actually i was having no idea about that , so it's okay for MSVC.

for gcc my ext is okay , but is there a way to know which one is used MSVC or GCC at parse time.