以文本方式查看主题

-  Fortran中文网  (http://fortran.cn/bbs/index.asp)
--  Fortran语言开发经验交流  (http://fortran.cn/bbs/list.asp?boardid=3)
----  大家看一下这个例子彭国伦书上的画图的例子!  (http://fortran.cn/bbs/dispbbs.asp?boardid=3&id=1470)

--  作者:edongliang
--  发布时间:2008/5/7 9:17:59

--  大家看一下这个例子彭国伦书上的画图的例子!
大家看一下这个例子我运行以后怎么总是有错误,哪位高手给详细说明下是怎么回事?我是用console Applation 建立的工程 自由格式运行以后出现,

INK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library

sglui2.obj : error LNK2001: unresolved external symbol _SGLDRAWLINE@16

Debug/76.exe : fatal error LNK1120: 1 unresolved externals

Error executing link.exe.

76.exe - 2 error(s), 1 warning(s)

这是怎么回事啊?源程序如下

module sgl_util

  use sgl

  implicit none

  integer, save :: x=0

  integer, save :: y=0

contains

subroutine display()

  integer, parameter :: size = 10

  call sglClearBuffer()

  call sglColor3i(255,255,255)

! call sglDrawLine(x-size, y-size, x+size, y+size)

!  call sglDrawLine(x+size, y-size, x-size, y+size)

  call sglUpdateBuffer()

  return

end subroutine

subroutine MouseMove(mx,my)

  integer mx,my

  x = mx

  y = my

  call display()

  return

end subroutine

subroutine MouseDown(key)

  integer key

  write(*,"(\'Push mouse button \',I1)") key

end subroutine

subroutine MouseUp(key)

  integer key

  write(*,"(\'Release mouse button \',I1)") key

end subroutine

end module

program main

  use sgl_util

  implicit none

  ! 设定鼠标在窗口中移动时, 会调用MouseMove

  call sglMouseMoveSub(MouseMove)

  ! 设定鼠标在窗口按下按钮时, 会调用MouseDown

  call sglMouseDownSub(MouseDown) !

  ! 设定鼠标在窗口松开按钮时, 会调用MouseDown

  call sglMouseUpSub(MouseUp)

  call sglDisplaySub(display)

  call sglCreateWindow(100,100,400,400,1)

  call sglShowCursor(0) ! 隐藏操作系统的鼠标光标

  call sglMainLoop()

  stop

end program


--  作者:lm_lxt
--  发布时间:2008/5/7 12:03:28

--  
好像http://bbs.pfan.cn/论坛里出现过类似的问题,找找看
--  作者:edongliang
--  发布时间:2008/5/7 18:28:39

--  

那个帖子我回了我把程序加进去就行了我回他了


--  作者:珊瑚虫
--  发布时间:2008/5/8 17:20:01

--  

这个程序是有问题

以下是我改的

module sgl_util
  use sgl
  implicit none
  integer, save :: x=0
  integer, save :: y=0
contains
subroutine display()
  integer, parameter :: size = 10
  call sglClearBuffer()
  call sglColor3i(255,255,255)
  call sglLine(x-size, y-size, x+size, y+size)
  call sglLine(x+size, y-size, x-size, y+size)
  call sglUpdateBuffer()
  return
end subroutine
subroutine MouseMove(mx,my)
  integer mx,my
  x = mx
  y = my
  call display()
  return
end subroutine
subroutine MouseDown(key,x,y)
  integer key,x,y
  write(*,"(\'Push mouse button \',I1)") key
  write(*,*)\'坐标:\',x,y
end subroutine
subroutine MouseUp(key,x,y)
  integer key,x,y
  write(*,"(\'Release mouse button \',I1)") key
end subroutine
end module

program main
  use sgl_util
  implicit none
  call sglMouseMoveSub(MouseMove)
  call sglMouseDownSub(MouseDown)
  call sglMouseupSub(Mouseup)
  call sglDisplaySub(display)
  call sglCreateWindow(100,100,400,400,1)
  call sglShowCursor(0)
  call sglMainLoop()
  stop
end program

大概是他在调用MouseUp(key,x,y)这几个子程序是变量有问题吧

这样改了之后就好了


京ICP备05056801号